Skip to content

Commit

Permalink
add fare_media, fare_products fare_transfer_rule to sidebar to view data
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-willis-arcadis committed Jan 30, 2025
1 parent 5d38fbb commit a9bedf7
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 14 deletions.
59 changes: 56 additions & 3 deletions gtfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,9 @@
- name: added_service
required: false

- id: fare_products
# Fares v2

- id: fare_product
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:
Expand All @@ -1028,12 +1030,63 @@
- name: fare_product_name
required: false
inputType: TEXT
- name: fare_product_id
- name: fare_media_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
inputType: TEXT # FARE-TODO: Dropdownx
- id: fare_media
name: fare_media.txt
helpContent: To describe the different fare media that can be employed to use fare products. Fare media are physical or virtual holders used for the representation and/or validation of a fare product.
fields:
- name: fare_media_id
required: true
inputType: GTFS_ID
- name: fare_media_name
inputType: TEXT
- name: fare_media_type
required: true
inputType: DROPDOWN
# FARE-TODO: Some help content?
options:
- value: '0'
- value: '1'
- value: '2'
- value: '3'
- value: '4'
- id: fare_transfer_rule
name: fare_transfer_rules.txt
helpContent: Fare rules for transfers between legs of travel defined in fare_leg_rules.txt.
fields:
- name: from_leg_group_id
required: false
inputType: TEXT # FARE-TODO: Needs to reference fare_leg_rules
- name: to_leg_group_id
required: false
inputType: TEXT # FARE-TODO: Needs to reference fare_leg_rules
- name: transfer_count
inputType: NUMBER # FARE-TODO: NON-ZERO INT
- name: duration_limit
inputType: POSITIVE_INT
- name: duration_limit_type
inputType: DROPDOWN
# FARE-TODO: Some help content?
options:
- value: '0'
- value: '1'
- value: '2'
- value: '3'
- name: fare_transfer_type
inputType: DROPDOWN
# FARE-TODO: Some help content?
options:
- value: '0'
- value: '1'
- value: '2'
- name: fare_product_id
required: false
inputType: TEXT # FARE-TODO: Needs to reference fare_products
12 changes: 12 additions & 0 deletions lib/editor/actions/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,18 @@ export function fetchBaseGtfs ({
fare_product (limit: -1) {
id
fare_product_id
fare_media_id
}
fare_media (limit: -1) {
id
fare_media_id
}
fare_transfer_rule (limit: -1) {
from_leg_group_id
to_leg_group_id
fare_product_id
transfer_count
duration_limit
}
routes (limit: -1) {
id
Expand Down
12 changes: 9 additions & 3 deletions lib/editor/util/gtfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export const COMPONENT_LIST = [
{ id: 'calendar', tableName: 'calendar' },
{ id: 'scheduleexception', tableName: 'schedule_exceptions' },
{ id: 'agency', tableName: 'agency' },
{ id: 'fare_product', tableName: 'fare_products' }
{ id: 'fare_product', tableName: 'fare_product' },
{ id: 'fare_media', tableName: 'fare_media' },
{ id: 'fare_transfer_rule', tableName: 'fare_transfer_rule' }
]

export function getTableById (tableData: any, id?: string, emptyArrayOnNull: boolean = true): any {
Expand Down Expand Up @@ -242,8 +244,12 @@ export function getEntityName (entity: any): string {
} else if (typeof entity.fare_id !== 'undefined') {
nameKey = 'fare_id'
} else if (typeof entity.fare_product_id !== 'undefined') {
nameKey = 'fare_product_id'
} if (typeof entity.exemplar !== 'undefined') {
nameKey = 'fare_product_id' // FARE-TODO: fare_product_name?
} else if (typeof entity.fare_media_id !== 'undefined') {
nameKey = 'fare_media_id' // FARE-TODO: fare_media_name? Some combo?
}
// FARE-TODO: what to do with fare_transfer_rules.txt?
if (typeof entity.exemplar !== 'undefined') {
nameKey = 'name'
}

Expand Down
24 changes: 20 additions & 4 deletions lib/editor/util/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,27 @@ export const GTFS_ICONS = [
},
{
id: 'fare_product',
tableName: 'fare_products',
icon: 'ticket',
tableName: 'fare_product',
icon: 'shopping-cart',
addable: true,
title: 'FARE PRODUCT TEST TITLE',
label: 'FARE PRODUCT TEST LABEL'
},
{
id: 'fare_media',
tableName: 'fare_media',
icon: 'id-card',
addable: true,
title: 'FARE MEDIA TEST TITLE',
label: 'FARE MEDIA TEST LABEL'
},
{
id: 'fare_transfer_rule',
tableName: 'fare_transfer_rule',
icon: 'link',
addable: true,
title: 'FARE PRODUCTS TEST TITLE',
label: 'FARE PRODUCTS TEST LABEL'
title: 'FARE TRANSFER RULE TEST TITLE',
label: 'FARE TRANSFER RULE TEST LABEL'
}
]

Expand Down
25 changes: 23 additions & 2 deletions lib/gtfs/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export function getEntityIdField (type: string): string {
return 'fare_id'
case 'fare_product':
return 'fare_product_id'
case 'fare_media':
return 'fare_media_id'
case 'fare_transfer_rule':
return 'id'
// FARE-TODO: what to do with fare_transfer_rules.txt
case 'calendar':
return 'service_id'
case 'stop':
Expand Down Expand Up @@ -109,6 +114,14 @@ export function getGraphQLFieldsForEntity (type: string, editor: boolean = false
return `
${fields}
`
case 'fare_media':
return `
${fields}
`
case 'fare_transfer_rule':
return `
${fields}
`
case 'pattern':
return `
shape_id
Expand Down Expand Up @@ -149,7 +162,11 @@ export function getEntityGraphQLRoot (type: string): string {
case 'fare':
return 'fares'
case 'fare_product':
return 'fare_products'
return 'fare_product'
case 'fare_media':
return 'fare_media'
case 'fare_transer_rule':
return 'fare_transfer_rule'
case 'feedinfo':
return 'feed_info'
case 'stop':
Expand Down Expand Up @@ -184,9 +201,13 @@ export function getEntityTableString (type: string): string {
case 'fare':
return 'fare_attributes'
case 'fare_product':
return 'fare_products'
return 'fare_product'
case 'fare_media':
return 'fare_media'
case 'fare_rules':
return 'fare_rules'
case 'fare_transfer_rule':
return 'fare_transfer_rules'
case 'feedinfo':
return 'feedinfo'
case 'stop':
Expand Down
6 changes: 4 additions & 2 deletions lib/types/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ export type EditorTables = {
id: number,
service_id: string
}>,
fare_products: Array<{}>,
fare_media: Array<{}>, // FARE-TODO: Do this
fare_product: Array<{}>, // FARE-TODO: Do this
fare_transfer_rule: Array<{}>, // FARE-TODO: Do this
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 a9bedf7

Please sign in to comment.