Skip to content

Commit

Permalink
Merge pull request #6336 from leonardehrenfried/debug-ui-cost
Browse files Browse the repository at this point in the history
Show generalized cost in debug UI
  • Loading branch information
leonardehrenfried authored Dec 17, 2024
2 parents e130997 + edcba5a commit b04dc99
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions client/src/components/ItineraryList/ItineraryDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function ItineraryDetails({ tripPattern }: { tripPattern: TripPattern })
{tripPattern.legs.map((leg, i) => (
<ItineraryLegDetails key={leg.id ? leg.id : `noid_${i}`} leg={leg} isLast={i === tripPattern.legs.length - 1} />
))}

<div className="generalized-cost">Generalized cost: ¢{tripPattern.generalizedCost}</div>
</div>
);
}
3 changes: 2 additions & 1 deletion client/src/components/ItineraryList/ItineraryLegDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export function ItineraryLegDetails({ leg, isLast }: { leg: Leg; isLast: boolean
return (
<div className="itinerary-leg-details">
<div className="times">
{formatDistance(leg.distance)}, {formatDuration(leg.duration)}
{formatDistance(leg.distance)}, {formatDuration(leg.duration)},{' '}
<span title={'Generalized cost: ¢' + leg.generalizedCost}>¢{leg.generalizedCost}</span>
</div>
<InterchangeInfo leg={leg} />
<LegTime
Expand Down
2 changes: 2 additions & 0 deletions client/src/static/query/tripQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const query = graphql(`
expectedStartTime
duration
distance
generalizedCost
legs {
id
mode
Expand All @@ -45,6 +46,7 @@ export const query = graphql(`
realtime
distance
duration
generalizedCost
fromPlace {
name
quay {
Expand Down
6 changes: 6 additions & 0 deletions client/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
font-size: 11px;
}

.accordion-body .generalized-cost {
font-size: 11px;
text-align: end;
margin-right: 9px;
}

.itinerary-leg-details .mode {
margin-top: 2px;
}
Expand Down
18 changes: 6 additions & 12 deletions client/src/util/formatDuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@ export function formatDuration(seconds: number) {

let formatted = '';

if (hrs === 1) {
formatted = `${formatted}${hrs} hr `;
} else if (hrs > 1) {
formatted = `${formatted}${hrs} hrs `;
if (hrs > 0) {
formatted = `${formatted}${hrs}h `;
}

if (mins === 1) {
formatted = `${formatted}${mins} min `;
} else if (mins > 1) {
formatted = `${formatted}${mins} mins `;
if (mins > 0) {
formatted = `${formatted}${mins}min `;
}

if (secs === 1) {
formatted = `${formatted}${secs} sec `;
} else if (secs > 1) {
formatted = `${formatted}${secs} secs `;
if (secs > 1) {
formatted = `${formatted}${secs}s`;
}

return formatted;
Expand Down

0 comments on commit b04dc99

Please sign in to comment.