Skip to content

Commit

Permalink
Fix final CS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mzur committed Oct 11, 2023
1 parent 5dc354a commit de0659c
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public function index(Request $request, $tid, $uid)
$labelsRelation = $model->labels();

return $query
->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName())
->where($labelsRelation->getRelated()->user()->getQualifiedForeignKeyName(), $uid)
->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName)
->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid)
->select($ownerKeyName)
->distinct()
->pluck($ownerKeyName);
->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName())
->where($labelsRelation->getRelated()->user()->getQualifiedForeignKeyName(), $uid)
->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName)
->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid)
->select($ownerKeyName)
->distinct()
->pluck($ownerKeyName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public function index(Request $request, $tid, $lid)
$labelsRelation = $model->labels();

return $query
->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName())
->where($labelsRelation->getRelated()->label()->getQualifiedForeignKeyName(), $lid)
->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName)
->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid)
->select($ownerKeyName)
->distinct()
->pluck($ownerKeyName);
->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName())
->where($labelsRelation->getRelated()->label()->getQualifiedForeignKeyName(), $lid)
->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName)
->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid)
->select($ownerKeyName)
->distinct()
->pluck($ownerKeyName);
}
}
13 changes: 7 additions & 6 deletions app/Jobs/CloneImagesOrVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ private function copyImageAnnotation($volume, $copy, $selectedFileIds, $selected
'=',
'image_annotations.id'
)
->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('image_annotation_labels.label_id', $selectedLabelIds))
->whereIn('image_annotations.image_id', $selectedFileIds);
->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('image_annotation_labels.label_id', $selectedLabelIds))
->whereIn('image_annotations.image_id', $selectedFileIds);


// use unique ids, because an annotation with multiple labels would be duplicated
Expand Down Expand Up @@ -384,9 +384,9 @@ private function copyVideoAnnotation($volume, $copy, $selectedFileIds, $selected
'=',
'video_annotations.id'
)
->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('video_annotation_labels.label_id', $selectedLabelIds))
->whereIn('video_annotations.video_id', $selectedFileIds)
->distinct();
->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('video_annotation_labels.label_id', $selectedLabelIds))
->whereIn('video_annotations.video_id', $selectedFileIds)
->distinct();

// use unique ids, because an annotation with multiple labels would be duplicated
$usedAnnotationIds = $annotationJoinLabel
Expand Down Expand Up @@ -480,7 +480,8 @@ private function copyVideoLabels($volume, $copy, $selectedFileIds, $selectedLabe
fn ($q) => $q->with('labels')
)
->orderBy('id')
->get()->map(function ($oldVideo) use ($newVideoIds) {
->get()
->map(function ($oldVideo) use ($newVideoIds) {
$newVideoId = $newVideoIds->shift();
$oldVideo->labels->map(function ($oldLabel) use ($newVideoId) {
$origin = $oldLabel->getRawOriginal();
Expand Down
6 changes: 2 additions & 4 deletions app/Jobs/ProcessNewImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ protected function makeThumbnail(Image $image, $path)
{
$prefix = fragment_uuid_path($image->uuid);
$format = config('thumbnails.format');
$buffer = VipsImage::thumbnail($path, $this->width, [
'height' => $this->height,
])
$buffer = VipsImage::thumbnail($path, $this->width, ['height' => $this->height])
// Strip EXIF information to not auto rotate thumbnails because
// the orientation of AUV captured images is not reliable.
->writeToBuffer(".{$format}", [
Expand All @@ -137,7 +135,7 @@ protected function makeThumbnail(Image $image, $path)
]);

Storage::disk(config('thumbnails.storage_disk'))
->put("{$prefix}.{$format}", $buffer);
->put("{$prefix}.{$format}", $buffer);
}

/**
Expand Down
12 changes: 4 additions & 8 deletions app/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,10 @@ public function getThumbnailUrlAttribute()
public function hasGeoInfo()
{
return Cache::remember("project-{$this->id}-has-geo-info", 3600, function () {
return Image::whereIn('volume_id', function ($query) {
return $query->select('volume_id')
->from('project_volume')
->where('project_id', $this->id);
})
->whereNotNull('lng')
->whereNotNull('lat')
->exists();
return Image::whereIn('volume_id', fn ($q) => $q->select('volume_id')->from('project_volume')->where('project_id', $this->id))
->whereNotNull('lng')
->whereNotNull('lat')
->exists();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ public function testJoinRedirect()
$pid = $this->project()->id;

$this->beUser();
$this->post("/api/v1/project-invitations/{$id}/join", [
'token' => $invitation->uuid,
])
$this
->post("/api/v1/project-invitations/{$id}/join", [
'token' => $invitation->uuid,
])
->assertRedirect("projects/{$pid}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ public function testStoreFilesExistException()
FileCache::shouldReceive('exists')
->andThrow(new Exception('Invalid MIME type.'));

$response =
$this->postJson("/api/v1/projects/{$id}/volumes", [
$response = $this
->postJson("/api/v1/projects/{$id}/volumes", [
'name' => 'my volume no. 1',
'url' => 'test://images',
'media_type' => 'image',
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Http/Controllers/Api/VolumeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ public function testUpdateRedirect()

public function testCloneVolume()
{
$volume =
$this->volume([
$volume = $this
->volume([
'created_at' => '2022-11-09 14:37:00',
'updated_at' => '2022-11-09 14:37:00',
])
Expand Down
8 changes: 4 additions & 4 deletions tests/php/Http/Controllers/Api/VolumeFileControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testStoreImage()
])
->assertStatus(422);

$response =
$response =
$this->json('POST', "/api/v1/volumes/{$id}/files", [
'files' => '1.jpg, 2.jpg',
]);
Expand Down Expand Up @@ -203,7 +203,7 @@ public function testStoreVideo()
])
->assertStatus(422);

$response =
$response =
$this->json('POST', "/api/v1/volumes/{$id}/files", [
'files' => '1.mp4, 2.mp4',
]);
Expand Down Expand Up @@ -270,8 +270,8 @@ public function testStoreFilesExistException()
FileCache::shouldReceive('exists')
->andThrow(new Exception('Invalid MIME type.'));

$response =
$this->postJson("/api/v1/volumes/{$id}/files", [
$response = $this
->postJson("/api/v1/volumes/{$id}/files", [
'files' => '1.jpg',
])
->assertStatus(422);
Expand Down
Loading

0 comments on commit de0659c

Please sign in to comment.