mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(dayplan): sort the trip's dates with an explicit compare
ISO dates sort the same as plain strings, but a sort without a compare function reads as an accident to anyone checking it, and SonarCloud flags it as one. The three places that order the trip's dates now say how.
This commit is contained in:
@@ -209,7 +209,7 @@ export class DayRemovalService {
|
||||
*/
|
||||
private renumber(tripId: number, rows: DayRow[], remaining: DayRow[]): string | null {
|
||||
// ISO dates sort as plain strings.
|
||||
const sortedDates = rows.map(r => r.date).filter((d): d is string => !!d).sort();
|
||||
const sortedDates = rows.map(r => r.date).filter((d): d is string => !!d).sort((a, b) => a.localeCompare(b));
|
||||
const setNumber = this.db.prepare('UPDATE days SET day_number = ? WHERE id = ?');
|
||||
const setNumberAndDate = this.db.prepare('UPDATE days SET day_number = ?, date = ? WHERE id = ?');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user