diff --git a/app/Console/Commands/FlightFeedUpdate.php b/app/Console/Commands/FlightFeedUpdate.php new file mode 100644 index 0000000..0a051bf --- /dev/null +++ b/app/Console/Commands/FlightFeedUpdate.php @@ -0,0 +1,38 @@ +logFlightActions('flight_departing', UserFlight::where('departure_date', $time)->get()->toArray()); + $this->logFlightActions('flight_arriving', UserFlight::where('arrival_date', $time)->get()->toArray()); + } + + /** + * @param string $type + * @param UserFlight[] $flights + * @return void + */ + private function logFlightActions(string $type, array $flights): void + { + foreach ($flights as $flight) { + UserAction::create([ + 'user_id' => $flight->user_id, + 'type' => $type, + 'data' => $flight->snapshot($flight->id), + ]); + } + } +} diff --git a/resources/js/Components/FlightsGoneBy/Feed/FeedItem.vue b/resources/js/Components/FlightsGoneBy/Feed/FeedItem.vue index 28cbd00..9f271c8 100644 --- a/resources/js/Components/FlightsGoneBy/Feed/FeedItem.vue +++ b/resources/js/Components/FlightsGoneBy/Feed/FeedItem.vue @@ -12,6 +12,7 @@ import {Link} from "@inertiajs/vue3"; import FlightUpdatedFeedItem from "@/Components/FlightsGoneBy/Feed/FlightUpdatedFeedItem.vue"; import FlightCancelledFeedItem from "@/Components/FlightsGoneBy/Feed/FlightCancelledFeedItem.vue"; import FlightImportedFeedItem from "@/Components/FlightsGoneBy/Feed/FlightImportedFeedItem.vue"; +import FlightMovedFeedItem from "@/Components/FlightsGoneBy/Feed/FlightMovedFeedItem.vue"; const props = defineProps<{ action: UserAction @@ -31,6 +32,8 @@ const badgeVariant = computed(() => { switch (props.action.type) { case 'flight_booked': return 'generic' case 'flight_logged': return 'generic' + case 'flight_departing': return 'generic' + case 'flight_arriving': return 'generic' case 'flight_imported': return 'economy' case 'flight_updated': return 'economy' case 'flight_cancelled': return 'crew' @@ -74,6 +77,7 @@ function timeAgo(dateStr: string): string { + /
diff --git a/resources/js/Components/FlightsGoneBy/Feed/FlightMovedFeedItem.vue b/resources/js/Components/FlightsGoneBy/Feed/FlightMovedFeedItem.vue new file mode 100644 index 0000000..bc7a7ac --- /dev/null +++ b/resources/js/Components/FlightsGoneBy/Feed/FlightMovedFeedItem.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/resources/js/Types/types.d.ts b/resources/js/Types/types.d.ts index 6597b52..c8b124b 100644 --- a/resources/js/Types/types.d.ts +++ b/resources/js/Types/types.d.ts @@ -19,7 +19,7 @@ export interface User { email_verified_at: string | null } -export type UserActionType = "flight_cancelled" | "flight_booked" | "flight_updated" | "flight_logged" | "flight_deleted" | "flight_imported" +export type UserActionType = "flight_cancelled" | "flight_booked" | "flight_updated" | "flight_logged" | "flight_deleted" | "flight_imported" | "flight_departing" | "flight_arriving" export type UserActionDataKey = "field" | "from" | "to" export type UserActionFlightBookedData = { diff --git a/routes/console.php b/routes/console.php index 6188b31..2a8ee45 100644 --- a/routes/console.php +++ b/routes/console.php @@ -3,8 +3,5 @@ use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\Artisan; -Artisan::command('inspire', function () { - $this->comment(Inspiring::quote()); -})->purpose('Display an inspiring quote'); - Schedule::command('app:update-departed-flights')->hourly()->runInBackground(); +Schedule::command('app:flight-feed-update')->everyMinute()->runInBackground();