Skip to content

Commit

Permalink
Dark mode (#68)
Browse files Browse the repository at this point in the history
* added dark mode

* Apply fixes from StyleCI (#66)

Co-authored-by: Andrew <akmolina28@users.noreply.github.com>

* Apply fixes from StyleCI (#67)

Co-authored-by: Andrew <akmolina28@users.noreply.github.com>

* Roll back php version due to errors in travis ci build

Co-authored-by: Andrew <akmolina28@users.noreply.github.com>
  • Loading branch information
akmolina28 and akmolina28 authored Oct 27, 2021
1 parent a0dde13 commit 688d40e
Show file tree
Hide file tree
Showing 38 changed files with 704 additions and 323 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
language: generic
sudo: required

env:
- DOCKER_COMPOSE_VERSION=1.29.2

branches:
only:
- master
Expand Down
2 changes: 1 addition & 1 deletion php.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-fpm
FROM php:7.4-fpm-buster

ARG USER_ID
ARG GROUP_ID
Expand Down
2 changes: 2 additions & 0 deletions src/app/AiPrediction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* AiPrediction.
*
* @mixin Eloquent
*
* @property int $id
* @property int $detection_event_id
* @property string $object_class
Expand All @@ -25,6 +26,7 @@
* @property-read DetectionEvent $detectionEvent
* @property-read Collection|DetectionProfile[] $detectionProfiles
* @property-read int|null $detection_profiles_count
*
* @method static Builder|AiPrediction newModelQuery()
* @method static Builder|AiPrediction newQuery()
* @method static Builder|AiPrediction query()
Expand Down
4 changes: 4 additions & 0 deletions src/app/AutomationConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $deleted_at
*
* @method static Builder|AutomationConfig newModelQuery()
* @method static Builder|AutomationConfig newQuery()
* @method static Builder|AutomationConfig query()
Expand All @@ -31,10 +32,13 @@
* @method static Builder|AutomationConfig whereId($value)
* @method static Builder|AutomationConfig whereUpdatedAt($value)
* @mixin Eloquent
*
* @method static Builder|AutomationConfig onlyTrashed()
* @method static Builder|AutomationConfig withTrashed()
* @method static Builder|AutomationConfig withoutTrashed()
*
* @property bool $is_high_priority
*
* @method static Builder|AutomationConfig whereIsHighPriority($value)
*/
class AutomationConfig extends Model
Expand Down
5 changes: 5 additions & 0 deletions src/app/DeepstackCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
* App\DeepstackCall.
*
* @property-read mixed $run_time_seconds
*
* @method static Builder|DeepstackCall newModelQuery()
* @method static Builder|DeepstackCall newQuery()
* @method static Builder|DeepstackCall query()
* @mixin Eloquent
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
Expand All @@ -25,6 +27,7 @@
* @property int $is_error
* @property int $runTimeSeconds
* @property array $predictions
*
* @method static Builder|DeepstackCall whereCalledAt($value)
* @method static Builder|DeepstackCall whereCreatedAt($value)
* @method static Builder|DeepstackCall whereId($value)
Expand All @@ -33,7 +36,9 @@
* @method static Builder|DeepstackCall whereResponseJson($value)
* @method static Builder|DeepstackCall whereReturnedAt($value)
* @method static Builder|DeepstackCall whereUpdatedAt($value)
*
* @property int $detection_event_id
*
* @method static Builder|DeepstackCall whereDetectionEventId($value)
*/
class DeepstackCall extends Model
Expand Down
3 changes: 2 additions & 1 deletion src/app/DeepstackClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class DeepstackClient implements DeepstackClientInterface

/**
* DeepstackClient constructor.
* @param string $api_base_url
*
* @param string $api_base_url
*/
public function __construct(string $api_base_url)
{
Expand Down
4 changes: 4 additions & 0 deletions src/app/DetectionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* DetectionEvent.
*
* @mixin Eloquent
*
* @property int $id
* @property string $image_file_name
* @property string|null $deepstack_response
Expand All @@ -29,6 +30,7 @@
* @property-read int|null $ai_predictions_count
* @property-read Collection|DetectionProfile[] $patternMatchedProfiles
* @property-read int|null $pattern_matched_profiles_count
*
* @method static Builder|DetectionEvent newModelQuery()
* @method static Builder|DetectionEvent newQuery()
* @method static Builder|DetectionEvent query()
Expand All @@ -39,6 +41,7 @@
* @method static Builder|DetectionEvent whereImageFileName($value)
* @method static Builder|DetectionEvent whereOccurredAt($value)
* @method static Builder|DetectionEvent whereUpdatedAt($value)
*
* @property-read Collection|\App\DetectionEventAutomationResult[] $automations
* @property-read int|null $automations_count
* @property-read Collection|\App\DetectionEventAutomationResult[] $automationResults
Expand All @@ -48,6 +51,7 @@
* @property-read mixed $event_url
* @property-read mixed $image_url
* @property-read ImageFile|null $imageFile
*
* @method static Builder|DetectionEvent whereImageFileId($value)
*/
class DetectionEvent extends Model
Expand Down
2 changes: 2 additions & 0 deletions src/app/DetectionEventAutomationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @property int $automation_config_id
* @property int $is_error
* @property string|null $response_text
*
* @method static Builder|DetectionEventAutomationResult newModelQuery()
* @method static Builder|DetectionEventAutomationResult newQuery()
* @method static Builder|DetectionEventAutomationResult query()
Expand All @@ -28,6 +29,7 @@
* @method static Builder|DetectionEventAutomationResult whereResponseText($value)
* @method static Builder|DetectionEventAutomationResult whereUpdatedAt($value)
* @mixin Eloquent
*
* @property-read \App\AutomationConfig $automationConfig
* @property-read \App\DetectionEvent $detectionEvent
*/
Expand Down
4 changes: 4 additions & 0 deletions src/app/DetectionProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* DetectionProfile.
*
* @mixin Eloquent
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
Expand All @@ -39,6 +40,7 @@
* @property-read mixed $status
* @property-read Collection|DetectionEvent[] $patternMatchedEvents
* @property-read int|null $pattern_matched_events_count
*
* @method static Builder|DetectionProfile newModelQuery()
* @method static Builder|DetectionProfile newQuery()
* @method static Builder|DetectionProfile onlyTrashed()
Expand All @@ -62,8 +64,10 @@
* @method static Builder|DetectionProfile whereUseSmartFilter($value)
* @method static Builder|DetectionProfile withTrashed()
* @method static Builder|DetectionProfile withoutTrashed()
*
* @property-read Collection|AutomationConfig[] $automations
* @property-read int|null $automations_count
*
* @method static Builder|DetectionProfile whereIsNegative($value)
*/
class DetectionProfile extends Model
Expand Down
4 changes: 2 additions & 2 deletions src/app/Factories/DetectionEventModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class DetectionEventModelFactory
{
/**
* @param string $imageFileName
* @param Carbon|null $occurred_at
* @param string $imageFileName
* @param Carbon|null $occurred_at
* @return DetectionEvent|Model
*/
public static function createFromImageFile(string $imageFileName, Carbon $occurred_at = null)
Expand Down
9 changes: 7 additions & 2 deletions src/app/FolderCopyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* DetectionProfile.
*
* @mixin Eloquent
*
* @property int $id
* @property string $name
* @property string $copy_to
Expand All @@ -23,6 +24,7 @@
* @property Carbon|null $updated_at
* @property-read Collection|DetectionProfile[] $detectionProfiles
* @property-read int|null $detection_profiles_count
*
* @method static Builder|FolderCopyConfig newModelQuery()
* @method static Builder|FolderCopyConfig newQuery()
* @method static Builder|FolderCopyConfig query()
Expand All @@ -32,7 +34,9 @@
* @method static Builder|FolderCopyConfig whereName($value)
* @method static Builder|FolderCopyConfig whereOverwrite($value)
* @method static Builder|FolderCopyConfig whereUpdatedAt($value)
*
* @property Carbon|null $deleted_at
*
* @method static Builder|FolderCopyConfig onlyTrashed()
* @method static Builder|FolderCopyConfig whereDeletedAt($value)
* @method static Builder|FolderCopyConfig withTrashed()
Expand All @@ -52,9 +56,10 @@ public function detectionProfiles(): MorphToMany
}

/**
* @param DetectionEvent $event
* @param DetectionProfile $profile
* @param DetectionEvent $event
* @param DetectionProfile $profile
* @return bool
*
* @throws AutomationException
*/
public function run(DetectionEvent $event, DetectionProfile $profile): bool
Expand Down
14 changes: 6 additions & 8 deletions src/app/Http/Controllers/DetectionEventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ public function findNext(DetectionEvent $event)

$profileId = $matchedProfile->id;

$next = DetectionEvent::
whereHas('patternMatchedProfiles', function ($q) use ($profileId) {
return $q->where('pattern_match.detection_profile_id', '=', $profileId);
})
$next = DetectionEvent::whereHas('patternMatchedProfiles', function ($q) use ($profileId) {
return $q->where('pattern_match.detection_profile_id', '=', $profileId);
})
->where('occurred_at', '>=', $event->occurred_at)
->where('id', '!=', $event->id)
->orderBy('occurred_at')->first();
Expand All @@ -156,10 +155,9 @@ public function findPrev(DetectionEvent $event)

$profileId = $matchedProfile->id;

$prev = DetectionEvent::
whereHas('patternMatchedProfiles', function ($q) use ($profileId) {
return $q->where('pattern_match.detection_profile_id', '=', $profileId);
})
$prev = DetectionEvent::whereHas('patternMatchedProfiles', function ($q) use ($profileId) {
return $q->where('pattern_match.detection_profile_id', '=', $profileId);
})
->where('occurred_at', '<=', $event->occurred_at)
->where('id', '!=', $event->id)
->orderByDesc('occurred_at')->first();
Expand Down
3 changes: 1 addition & 2 deletions src/app/Http/Controllers/DetectionProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ public function showAutomations($param)
$query = null;

foreach ($configTypes as $type) {
$q = Relation::$morphMap[$type]
::leftJoin('automation_configs as ac', function ($join) use ($type, $profile) {
$q = Relation::$morphMap[$type]::leftJoin('automation_configs as ac', function ($join) use ($type, $profile) {
$join->on('ac.automation_config_id', '=', $type.'.id');
$join->where('ac.automation_config_type', '=', $type);
$join->whereNull('ac.deleted_at');
Expand Down
7 changes: 3 additions & 4 deletions src/app/Http/Controllers/StatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ class StatisticsController extends Controller
{
public function index()
{
$relevantEvents = DetectionEvent::
whereHas('detectionProfiles', function ($q) {
return $q->where('ai_prediction_detection_profile.is_masked', '=', false)
$relevantEvents = DetectionEvent::whereHas('detectionProfiles', function ($q) {
return $q->where('ai_prediction_detection_profile.is_masked', '=', false)
->where('ai_prediction_detection_profile.is_smart_filtered', '=', false);
})
})
->whereBetween('occurred_at', [
Date::now()->addDays(-1)->format('Y-m-d H:i:s'),
Date::now()->format('Y-m-d H:i:s'),
Expand Down
2 changes: 2 additions & 0 deletions src/app/ImageFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
* AiPrediction.
*
* @mixin Eloquent
*
* @property int $id
* @property string $file_name
* @property string $path
* @property int $width
* @property int $height
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @method static Builder|ImageFile newModelQuery()
* @method static Builder|ImageFile newQuery()
* @method static Builder|ImageFile query()
Expand Down
2 changes: 1 addition & 1 deletion src/app/Jobs/DeleteEventImageJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DeleteEventImageJob implements ShouldQueue
/**
* Create a new job instance.
*
* @param ImageFile $imageFile
* @param ImageFile $imageFile
*/
public function __construct(ImageFile $imageFile)
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/Jobs/ProcessAutomationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class ProcessAutomationJob implements ShouldQueue
/**
* Create a new job instance.
*
* @param DetectionProfile $profile
* @param DetectionEvent $event
* @param AutomationConfig $automation
* @param DetectionProfile $profile
* @param DetectionEvent $event
* @param AutomationConfig $automation
*/
public function __construct(DetectionProfile $profile, DetectionEvent $event, AutomationConfig $automation)
{
Expand Down
17 changes: 8 additions & 9 deletions src/app/Jobs/ProcessDetectionEventJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class ProcessDetectionEventJob implements ShouldQueue
/**
* Create a new job instance.
*
* @param DetectionEvent $event
* @param array $settings
* @param DetectionEvent $event
* @param array $settings
*/
public function __construct(DetectionEvent $event, array $compressionSettings = [])
{
Expand All @@ -39,8 +39,9 @@ public function __construct(DetectionEvent $event, array $compressionSettings =
/**
* Execute the job.
*
* @param DeepstackClientInterface $client
* @param DeepstackClientInterface $client
* @return void
*
* @throws FileNotFoundException
*/
public function handle(DeepstackClientInterface $client)
Expand Down Expand Up @@ -74,11 +75,10 @@ public function handle(DeepstackClientInterface $client)
'detection_event_id' => $this->event->id,
]);

$matchedProfiles = DetectionProfile::
whereHas('patternMatchedEvents', function ($query) {
$query->where('detection_event_id', '=', $this->event->id)
$matchedProfiles = DetectionProfile::whereHas('patternMatchedEvents', function ($query) {
$query->where('detection_event_id', '=', $this->event->id)
->where('is_profile_active', '=', 1);
})
})
->whereJsonContains('object_classes', $prediction->label)
->where('min_confidence', '<=', $prediction->confidence)
->get();
Expand Down Expand Up @@ -117,8 +117,7 @@ public function handle(DeepstackClientInterface $client)
}

// profiles with negative flag set which didn't have any relevant objects
$negativeProfiles = DetectionProfile
::where('is_negative', '=', 1)
$negativeProfiles = DetectionProfile::where('is_negative', '=', 1)
->whereHas('patternMatchedEvents', function ($query) {
$query
->where('detection_event_id', '=', $this->event->id)
Expand Down
4 changes: 2 additions & 2 deletions src/app/Jobs/ProcessEventUploadJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class ProcessEventUploadJob implements ShouldQueue
*
* @param $path
* @param $fileName
* @param Carbon $occurredAt
* @param array $compressionSettings
* @param Carbon $occurredAt
* @param array $compressionSettings
*/
public function __construct($path, $fileName, $occurredAt, array $compressionSettings = [])
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/Jobs/ProcessImageOptimizationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class ProcessImageOptimizationJob implements ShouldQueue
/**
* Create a new job instance.
*
* @param ImageFile $imageFile
* @param array $settings
* @param ImageFile $imageFile
* @param array $settings
*/
public function __construct(ImageFile $imageFile, array $settings = [])
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/MqttPublishConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* AiPrediction.
*
* @mixin Eloquent
*
* @property int $id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
Expand All @@ -34,6 +35,7 @@
* @property Carbon|null $deleted_at
* @property-read Collection|DetectionProfile[] $detectionProfiles
* @property-read int|null $detection_profiles_count
*
* @method static Builder|MqttPublishConfig newModelQuery()
* @method static Builder|MqttPublishConfig newQuery()
* @method static \Illuminate\Database\Query\Builder|MqttPublishConfig onlyTrashed()
Expand Down
Loading

0 comments on commit 688d40e

Please sign in to comment.