Skip to content

Commit fae5c2e

Browse files
committed
Linting
1 parent 29ed30b commit fae5c2e

2 files changed

Lines changed: 43 additions & 35 deletions

File tree

scripts/viewStatistics.ts

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,63 @@
11
import { db } from '../src/lib/server/db/index.js';
22

33
async function getTours() {
4-
return await db.selectFrom('tour').where('tour.approachAndReturnM', 'is not', null).selectAll().execute();
4+
return await db
5+
.selectFrom('tour')
6+
.where('tour.approachAndReturnM', 'is not', null)
7+
.selectAll()
8+
.execute();
59
}
610

711
async function getRsTours() {
8-
return await db.selectFrom('rideShareTour').where('rideShareTour.approachAndReturnM', 'is not', null).selectAll().execute();
12+
return await db
13+
.selectFrom('rideShareTour')
14+
.where('rideShareTour.approachAndReturnM', 'is not', null)
15+
.selectAll()
16+
.execute();
917
}
1018

1119
type Tours = Awaited<ReturnType<typeof getTours>>;
1220
type RsTours = Awaited<ReturnType<typeof getRsTours>>;
1321

1422
async function viewStatistics() {
15-
const tours = await getTours();
16-
const tourEntries = {
17-
all: createEntries(tours),
18-
cancelled: createEntries(tours.filter((t) => t.cancelled)),
19-
uncancelledTours: createEntries(tours.filter((t) => !t.cancelled))
20-
}
21-
22-
const rsTours = await getRsTours();
23-
const rsTourEntries = {
24-
all: createRsEntries(rsTours),
25-
cancelled: createRsEntries(rsTours.filter((t) => t.cancelled)),
26-
uncancelledTours: createRsEntries(rsTours.filter((t) => !t.cancelled))
27-
}
28-
console.log("TAXI");
29-
console.log(JSON.stringify(tourEntries,null,2));
30-
console.log();
31-
console.log("RIDE SHARE");
32-
console.log(JSON.stringify(rsTourEntries,null,2));
23+
const tours = await getTours();
24+
const tourEntries = {
25+
all: createEntries(tours),
26+
cancelled: createEntries(tours.filter((t) => t.cancelled)),
27+
uncancelledTours: createEntries(tours.filter((t) => !t.cancelled))
28+
};
29+
30+
const rsTours = await getRsTours();
31+
const rsTourEntries = {
32+
all: createRsEntries(rsTours),
33+
cancelled: createRsEntries(rsTours.filter((t) => t.cancelled)),
34+
uncancelledTours: createRsEntries(rsTours.filter((t) => !t.cancelled))
35+
};
36+
console.log('TAXI');
37+
console.log(JSON.stringify(tourEntries, null, 2));
38+
console.log();
39+
console.log('RIDE SHARE');
40+
console.log(JSON.stringify(rsTourEntries, null, 2));
3341
}
3442

3543
function createEntries(tours: Tours) {
36-
return {
37-
count: tours.length,
38-
approachAndReturnM: tours.reduce((prev, curr) => prev += curr.approachAndReturnM!, 0),
39-
fullyPayedM: tours.reduce((prev, curr) => prev += curr.fullyPayedM!, 0),
40-
occupiedM: tours.reduce((prev, curr) => prev+= curr.occupiedM!, 0)
41-
}
44+
return {
45+
count: tours.length,
46+
approachAndReturnM: tours.reduce((prev, curr) => (prev += curr.approachAndReturnM!), 0),
47+
fullyPayedM: tours.reduce((prev, curr) => (prev += curr.fullyPayedM!), 0),
48+
occupiedM: tours.reduce((prev, curr) => (prev += curr.occupiedM!), 0)
49+
};
4250
}
4351

4452
function createRsEntries(tours: RsTours) {
45-
return {
46-
count: tours.length,
47-
approachAndReturnM: tours.reduce((prev, curr) => prev += curr.approachAndReturnM!, 0),
48-
fullyPayedM: tours.reduce((prev, curr) => prev += curr.fullyPayedM!, 0),
49-
occupiedM: tours.reduce((prev, curr) => prev+= curr.occupiedM!, 0)
50-
}
53+
return {
54+
count: tours.length,
55+
approachAndReturnM: tours.reduce((prev, curr) => (prev += curr.approachAndReturnM!), 0),
56+
fullyPayedM: tours.reduce((prev, curr) => (prev += curr.fullyPayedM!), 0),
57+
occupiedM: tours.reduce((prev, curr) => (prev += curr.occupiedM!), 0)
58+
};
5159
}
5260

5361
viewStatistics().catch((error) => {
54-
console.error('Error in main function:', error);
62+
console.error('Error in main function:', error);
5563
});

src/lib/createStatistics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type { Itinerary, Leg } from '$lib/openapi';
66
import { polyLineToLatLngArray } from '$lib/util/polylineToGeoJSON';
77

88
export async function createStatistics() {
9-
await computeAndPersistStatistics('tour');
10-
await computeAndPersistStatistics('rideShareTour');
9+
await computeAndPersistStatistics('tour');
10+
await computeAndPersistStatistics('rideShareTour');
1111
}
1212

1313
async function tourQuery() {

0 commit comments

Comments
 (0)