This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
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
14 changed files
with
116 additions
and
59 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
5 changes: 0 additions & 5 deletions
5
prisma/migrations/20231119220003_add_date_format_pref/migration.sql
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
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
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,26 @@ | ||
import { FlightStatus, User } from '@prisma/client'; | ||
|
||
import { prisma } from '@app/prisma'; | ||
import { Logger } from '@app/lib/logger'; | ||
|
||
export async function getUserActiveFlights(userID: User['id']) { | ||
Logger.debug('Getting user=%s active flights', userID); | ||
const flights = await prisma.userFlight.findMany({ | ||
orderBy: { | ||
Flight: { | ||
estimatedGateDeparture: 'asc', | ||
}, | ||
}, | ||
where: { | ||
Flight: { | ||
status: { | ||
notIn: [FlightStatus.ARCHIVED, FlightStatus.CANCELED], | ||
}, | ||
}, | ||
userID, | ||
}, | ||
}); | ||
|
||
Logger.debug('Got user=%s active flights=%s', userID, flights.length); | ||
return flights; | ||
} |
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,26 @@ | ||
import { FlightStatus, User } from '@prisma/client'; | ||
|
||
import { prisma } from '@app/prisma'; | ||
import { Logger } from '@app/lib/logger'; | ||
|
||
export async function getUserArchivedFlights(userID: User['id']) { | ||
Logger.debug('Getting user=%s archived flights', userID); | ||
const flights = await prisma.userFlight.findMany({ | ||
orderBy: { | ||
Flight: { | ||
estimatedGateDeparture: 'desc', | ||
}, | ||
}, | ||
where: { | ||
Flight: { | ||
status: { | ||
in: [FlightStatus.ARCHIVED, FlightStatus.CANCELED], | ||
}, | ||
}, | ||
userID, | ||
}, | ||
}); | ||
|
||
Logger.debug('Got user=%s archived flights=%s', userID, flights.length); | ||
return flights; | ||
} |
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,27 @@ | ||
import { Flight, User } from '@prisma/client'; | ||
|
||
import { prisma } from '@app/prisma'; | ||
import { Logger } from '@app/lib/logger'; | ||
|
||
export async function saveFlightToUser( | ||
flightID: Flight['id'], | ||
userID: User['id'], | ||
) { | ||
Logger.debug('Adding flight[%s] to user[%s]', flightID, userID); | ||
|
||
const record = await prisma.userFlight.upsert({ | ||
create: { | ||
flightID, | ||
userID, | ||
}, | ||
update: {}, | ||
where: { | ||
flightID_userID: { | ||
flightID, | ||
userID, | ||
}, | ||
}, | ||
}); | ||
|
||
return record; | ||
} |
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