fix(atlas): count shared days for every member, keep routes and multi-day tours honest (STA-02)

A day of a tour that names nobody now counts for every member of the trip,
not only for its owner. In the planner an empty participant list means
everyone, and a full member list is stored back as empty, so members got
nothing for most shared tours. Only a day that names participants without
the user stays theirs. The tours of a shared trip on no day or only on
undated days are now named as not counting for members as well.

A whole route a multi-day tour's stages were planned from is no longer
dropped on the server as soon as any stage has a day. Each entry carries
derived_from_place_id and the shared summary leaves the route out only
while one of its stages is done, counted and in the period and type. A
route walked last year now still counts when a stage of it is planned for
next month or was left out because it fell through, in the Atlas and over
MCP alike.

A tour on several days is dated on the last of them, as is a recording on
no day, so it no longer counts while it is still under way.

The info text, the get_tour_activity_stats description and the wiki say so.
This commit is contained in:
Maurice
2026-10-20 13:51:46 +02:00
parent bde2ad2ca8
commit acc294dd8e
47 changed files with 233 additions and 123 deletions
@@ -36,9 +36,9 @@ export interface TourActivityRow extends TourActivityRefRow {
/**
* STA-02: one tour of a trip the user can open, once per day assignment it has
* (once with `assignment_id` NULL when it is on no day), with what the activity
* sums need: its plan's measures, the day's date, the trip's owner, and who the
* execution names as taking part (`participant_count`, and `joined` 1 when the
* user is one of them).
* sums need: its plan's measures, the import it was planned from, the day's
* date, and who the execution names as taking part (`participant_count`, and
* `joined` 1 when the user is one of them).
*/
export interface TourStatsExecutionRow {
place_id: number;
@@ -50,7 +50,6 @@ export interface TourStatsExecutionRow {
derived_from_place_id: number | null;
trip_id: number;
trip_title: string;
trip_owner_id: number;
assignment_id: number | null;
date: string | null;
participant_count: number;
@@ -191,7 +190,6 @@ export class TourActivitiesRepository extends TrekRepository<TourActivities> {
't.derived_from_place_id as derived_from_place_id',
'tr.id as trip_id',
'tr.title as trip_title',
'tr.user_id as trip_owner_id',
'da.id as assignment_id',
'd.date as date',
eb