-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
748 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
# GitHub recommends pinning actions to a commit SHA. | ||
# To get a newer version, you will need to update the SHA. | ||
# You can also reference a tag or branch, but the action may change without warning. | ||
|
||
name: Deploy to Amazon ECR | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
AWS_REGION: eu-west-1 # set this to your preferred AWS region, e.g. us-west-1 | ||
ECR_REPOSITORY: hero/web # set this to your Amazon ECR repository name | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
IMAGE_TAG: latest | ||
#IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
# Build a docker container and | ||
# push it to ECR so that it can | ||
# be deployed to ECS. | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f ./deployment/web-dev.dockerfile . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Actions\Photos; | ||
|
||
use Illuminate\Http\UploadedFile; | ||
use Intervention\Image\Drivers\Gd\Driver; | ||
use Intervention\Image\ImageManager; | ||
|
||
class ExtractLocationFromPhotoAction implements ExtractsLocationFromPhoto | ||
{ | ||
public function run(UploadedFile $photo): array | ||
{ | ||
$manager = new ImageManager(new Driver()); | ||
$image = $manager->read($photo); | ||
$all = $image->exif('GPS'); | ||
|
||
if (! $all) { | ||
return []; | ||
} | ||
|
||
return $this->convertArrayToLatLng($all); | ||
} | ||
|
||
private function convertArrayToLatLng($gpsData) | ||
{ | ||
$GPSLatitudeRef = $gpsData['GPSLatitudeRef']; | ||
$GPSLatitude = $gpsData['GPSLatitude']; | ||
$GPSLongitudeRef = $gpsData['GPSLongitudeRef']; | ||
$GPSLongitude = $gpsData['GPSLongitude']; | ||
|
||
$lat_degrees = $this->gps2Num($GPSLatitude[0] ?? null); | ||
$lat_minutes = $this->gps2Num($GPSLatitude[1] ?? null); | ||
$lat_seconds = $this->gps2Num($GPSLatitude[2] ?? null); | ||
|
||
$lon_degrees = $this->gps2Num($GPSLongitude[0] ?? null); | ||
$lon_minutes = $this->gps2Num($GPSLongitude[1] ?? null); | ||
$lon_seconds = $this->gps2Num($GPSLongitude[2] ?? null); | ||
|
||
$lat_direction = ($GPSLatitudeRef == 'W' || $GPSLatitudeRef == 'S') ? -1 : 1; | ||
$lon_direction = ($GPSLongitudeRef == 'W' || $GPSLongitudeRef == 'S') ? -1 : 1; | ||
|
||
$latitude = $lat_direction * ($lat_degrees + ($lat_minutes / 60) + ($lat_seconds / (60 * 60))); | ||
$longitude = $lon_direction * ($lon_degrees + ($lon_minutes / 60) + ($lon_seconds / (60 * 60))); | ||
|
||
return ['latitude' => $latitude, 'longitude' => $longitude]; | ||
} | ||
|
||
private function gps2Num($coordPart) | ||
{ | ||
if (! $coordPart) { | ||
return 0; | ||
} | ||
|
||
$parts = explode('/', $coordPart); | ||
if (count($parts) <= 0) { | ||
return 0; | ||
} | ||
|
||
if (count($parts) == 1) { | ||
return $parts[0]; | ||
} | ||
|
||
return (float) $parts[0] / (float) $parts[1]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Actions\Photos; | ||
|
||
use Illuminate\Http\UploadedFile; | ||
|
||
interface ExtractsLocationFromPhoto | ||
{ | ||
public function run(UploadedFile $photo): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\User; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
use function Laravel\Prompts\progress; | ||
|
||
class GenerateRandomPhotos extends Command | ||
{ | ||
protected $signature = 'app:generate-random-photos'; | ||
|
||
public function handle(): void | ||
{ | ||
$user = User::query() | ||
->where('email', '[email protected]') | ||
->first(); | ||
|
||
$bar = progress('Generating 1M photos with tags...', 1_000_000); | ||
|
||
$bar->start(); | ||
|
||
$now = now()->toDateTimeString(); | ||
|
||
for ($i = 0; $i < 200; $i++) { | ||
$photos = []; | ||
$items = []; | ||
$tags = []; | ||
|
||
for ($j = 0; $j < 5000; $j++) { | ||
$photos[] = [ | ||
'user_id' => $user->id, | ||
'path' => 'photos/default.jpg', | ||
'created_at' => $now, | ||
'updated_at' => $now, | ||
]; | ||
} | ||
|
||
DB::table('photos')->insert($photos); | ||
|
||
for ($j = 0; $j < 5000; $j++) { | ||
$items[] = [ | ||
'photo_id' => $i * 5000 + $j + 2, | ||
'item_id' => random_int(1, 300), | ||
'picked_up' => 0, | ||
'recycled' => 0, | ||
'quantity' => 1, | ||
'created_at' => $now, | ||
'updated_at' => $now, | ||
]; | ||
} | ||
|
||
DB::table('photo_items')->insert($items); | ||
|
||
for ($k = 0; $k < 5000; $k++) { | ||
$tags[] = [ | ||
'photo_item_id' => $i * 5000 + $k + 1, | ||
'tag_id' => random_int(1, 1500), | ||
'created_at' => $now, | ||
'updated_at' => $now, | ||
]; | ||
} | ||
|
||
DB::table('photo_item_tag')->insert($tags); | ||
|
||
$bar->advance(5000); | ||
} | ||
|
||
$bar->finish(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\PhotoItem; | ||
|
||
class CopyPhotoItemController extends Controller | ||
{ | ||
public function __invoke(PhotoItem $photoItem): array | ||
{ | ||
$newPhotoItem = $photoItem->replicate(); | ||
$newPhotoItem->save(); | ||
|
||
$newPhotoItem->tags()->sync($photoItem->tags); | ||
|
||
return []; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.