Skip to content

Stats - #576

Open
nilspenzel wants to merge 13 commits into
motis-project:masterfrom
nilspenzel:stats
Open

Stats#576
nilspenzel wants to merge 13 commits into
motis-project:masterfrom
nilspenzel:stats

Conversation

@nilspenzel

Copy link
Copy Markdown
Contributor

Add scripts for computing and viewing some statistics

@traines-source traines-source left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, at least I can't think of anything important that we would be absolutely missing.
For reference, this was the script we once used to obtain some statistics:

SELECT l.distance as besetztkm, l.distance*request.passengers as personenkm, l.duration as besetztzeit, (tour.arrival-tour.departure)/1000 tourzeit, tour.departure as tour_start_ts, tour.arrival as tour_end_ts
FROM journey
JOIN request ON request.id = journey.request1
JOIN tour ON request.tour = tour.id
JOIN LATERAL jsonb_to_recordset(journey.json -> 'legs') AS l(distance numeric, duration numeric, mode text) ON true
WHERE NOT tour.cancelled
  AND NOT request.cancelled and request.ticket_checked  and l.mode = 'ODM';

Comment thread src/lib/createStatistics.ts Outdated
.innerJoin('company', 'company.id', 'vehicle.company')
.where('tour.arrival', '<', Date.now())
.where('tour.approachAndReturnM', 'is', null)
.where('tour.cancelled', '=', false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could also be interesting for cancelled tours?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. So far I avoided touching this since, #582 means there might be tours for which it is not trivial to tell which requests belonged to it before it was cancelled. So I will probably look at this issue before merging this.

@nilspenzel
nilspenzel marked this pull request as ready for review May 7, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants