Skip to content

Additional summary field for canceledTrips #7157

@partisaani

Description

@partisaani

Is your feature request related to a problem? Please describe.
I am in the process of creating a general alert/canceledTrips view for HSLdevcom/digitransit-ui. The core idea is to render the alerts and cancellations in simple card form. In case an alert affects several entities of same type OR if there are multiple canceledTrips, we'd like to group those under a single card or element and present them a bit like the following example:
🚌 [12:30] [12:35] [+2]
🚃 [10:00] [10:15] [+3]

However, in case of canceledTrips the grouping is not representing the overall status of the transportation system correctly if we cannot present the user with the exact amount of how many cancellations of certain mode the system holds in total. To underline the case let's take the following example where the system is set to query canceledTrips(first:5) and presents them to the user:
🚌 [12:30] [12:35] [+4]
🚃 [10:00]
But in reality the following page has 1...n more canceledTrip items for trams, metros and ferries that are not conveyed to the user in any way. The endpoint does return hasNextPage property which could be used in conjunction with a Load more CTA to query for more results, but this does not solve the issue of UI momentarily presenting the user with erroneous information about the system. The user would "just have to know" that even though the tram only lists one canceled trip, there may be more hiding somewhere. A weird loot box mechanic of sorts if you will.

Goal / high level use-case
A view with paged results is able to convey a more accurate state of the system to the user without having to fetch all of the results

Describe the solution you'd like
canceledTrips endpoint - or perhaps all of the endpoints which return paged data - is enriched with summary property which returns a high level snapshot of paged information i.e.

canceledTrips {
  pageinfo { ... }
  nodes { ... }
  summary {
    total: 72
    modes {
      bus: 50
      tram: 20
      metro: 2
    }
  }
}

Describe alternatives you've considered
Querying canceledTrips without first|last parameter but this is risky as there may be 1...n canceledTrips.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions