Skip to content

Commit

Permalink
Revert "Merge pull request #50 from kieler/23-service-improvements"
Browse files Browse the repository at this point in the history
This reverts commit 1548d6b, reversing
changes made to e07af0f.
  • Loading branch information
n1kPLV committed Aug 26, 2023
1 parent 9d712fb commit 982df79
Show file tree
Hide file tree
Showing 7 changed files with 721 additions and 833 deletions.
2 changes: 1 addition & 1 deletion Server/src/routes/init.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class InitRoute {
geometry: { type: "Point", coordinates: [pos.lng, pos.lat] },
properties: null
}
const currentTrack: Track | null = await TrackService.getClosestTrack(backendPos)
const currentTrack: Track | null = await VehicleService.getCurrentTrackForVehicle(backendPos)

if (!currentTrack) {
logger.error(`Could not find current track with position {lat : ${pos.lat}, lng : ${pos.lng}}`)
Expand Down
2 changes: 1 addition & 1 deletion Server/src/routes/track.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class TrackRoute {
} : undefined
// Also acquire the percentage position. It might happen that a percentage position is known, while the position is not.
// This might not make much sense.
const percentagePosition = (await VehicleService.getVehicleTrackDistancePercentage(vehicle)) ?? undefined
const percentagePosition = (await VehicleService.getVehicleTrackDistancePercentage(vehicle, track)) ?? undefined
const heading = await VehicleService.getVehicleHeading(vehicle)
return {
id: vehicle.uid,
Expand Down
33 changes: 18 additions & 15 deletions Server/src/services/db/log.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,32 @@ export default class LogController {
}
}

/**
/**
* Return a list of all logs. (Sorted: Descending by timestamp)
* If a trackerId is given the list will be filtered for this specific tracker.
* If a vehicleId is given the list will be filtered for this specific vehicle.
*
* @param limit - Number of entries this method should deliver. Default is all (undefined)
* @param vehicleId - Vehicle to filter for (Optional)
* @param trackerId - Tracker to filter for (Optional)
* @returns Log[] - List of all logs
*/
public async getAll(vehicleId?: number, trackerId?: string, limit?: number): Promise<Log[]> {
return await this.prisma.log.findMany({
where: {
vehicleId: vehicleId,
trackerId: trackerId
},
orderBy: [
{
timestamp: "desc"
}
],
take: limit
})
public async getAll(vehicleId?: number, trackerId?: string): Promise<Log[]> {
try {
return await this.prisma.log.findMany({
where: {
vehicleId: vehicleId,
trackerId: trackerId
},
orderBy: [
{
timestamp: "desc"
}
]
})
} catch (e) {
logger.debug(e)
return []
}
}

/**
Expand Down
Loading

0 comments on commit 982df79

Please sign in to comment.