Skip to content

Commit

Permalink
feat(gtfs): add initial CRUD for fare_products
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-willis-arcadis committed Jan 28, 2025
1 parent f044bbb commit 7d9e556
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
20 changes: 20 additions & 0 deletions gtfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1017,3 +1017,23 @@
required: false
- name: added_service
required: false

- id: fare_products
name: fare_products.txt
helpContent: Used to describe the range of fares available for purchase by riders or taken into account when computing the total fare for journeys with multiple legs, such as transfer costs.
fields:
- name: fare_product_id
required: true
inputType: GTFS_ID
- name: fare_product_name
required: false
inputType: TEXT
- name: fare_product_id
required: false
inputType: TEXT # FARE-TODO: Needs to reference an actual fare media id. need custom type
- name: amount
inputType: NUMBER
required: true
- name: currency
required: true
inputType: TEXT # FARE-TODO: Dropdownx
6 changes: 5 additions & 1 deletion lib/editor/actions/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,13 @@ export function fetchBaseGtfs ({
id
fare_id
}
fare_product (limit: -1) {
id
fare_product_id
}
routes (limit: -1) {
id
route_id
route_id
route_short_name
route_long_name
# Ensure that we know route type when setting active entity (for edit
Expand Down
7 changes: 5 additions & 2 deletions lib/editor/util/gtfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const COMPONENT_LIST = [
// FIXME: table name for calendar, fare, and schedule exception
{ id: 'calendar', tableName: 'calendar' },
{ id: 'scheduleexception', tableName: 'schedule_exceptions' },
{ id: 'agency', tableName: 'agency' }
{ id: 'agency', tableName: 'agency' },
{ id: 'fare_product', tableName: 'fare_products' }
]

export function getTableById (tableData: any, id?: string, emptyArrayOnNull: boolean = true): any {
Expand Down Expand Up @@ -240,7 +241,9 @@ export function getEntityName (entity: any): string {
nameKey = 'description'
} else if (typeof entity.fare_id !== 'undefined') {
nameKey = 'fare_id'
} else if (typeof entity.exemplar !== 'undefined') {
} else if (typeof entity.fare_product_id !== 'undefined') {
nameKey = 'fare_product_id'
} if (typeof entity.exemplar !== 'undefined') {
nameKey = 'name'
}

Expand Down
8 changes: 8 additions & 0 deletions lib/editor/util/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export const GTFS_ICONS = [
addable: true,
title: messages('fare.title'),
label: messages('fare.label')
},
{
id: 'fare_product',
tableName: 'fare_products',
icon: 'ticket',
addable: true,
title: 'FARE PRODUCTS TEST TITLE',
label: 'FARE PRODUCTS TEST LABEL'
}
]

Expand Down
10 changes: 10 additions & 0 deletions lib/gtfs/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export function getEntityIdField (type: string): string {
return 'agency_id'
case 'fare':
return 'fare_id'
case 'fare_product':
return 'fare_product_id'
case 'calendar':
return 'service_id'
case 'stop':
Expand Down Expand Up @@ -103,6 +105,10 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false
contains_id
}
`
case 'fare_product':
return `
${fields}
`
case 'pattern':
return `
shape_id
Expand Down Expand Up @@ -142,6 +148,8 @@ export function getEntityGraphQLRoot (type: string): string {
return 'calendar'
case 'fare':
return 'fares'
case 'fare_product':
return 'fare_products'
case 'feedinfo':
return 'feed_info'
case 'stop':
Expand Down Expand Up @@ -175,6 +183,8 @@ export function getEntityTableString (type: string): string {
return 'calendar'
case 'fare':
return 'fare_attributes'
case 'fare_product':
return 'fare_products'
case 'fare_rules':
return 'fare_rules'
case 'feedinfo':
Expand Down
3 changes: 2 additions & 1 deletion lib/types/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ export type EditorTables = {
id: number,
service_id: string
}>,
fare_products: Array<{}>,
fares: Array<{
fare_id: string,
id: number,
}>,
}>, // TODO: Do this
feed_info: Array<{
default_route_color: ?any,
default_route_type: ?any,
Expand Down

0 comments on commit 7d9e556

Please sign in to comment.