-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make the Dashboard page compatible with the new data model #1493
Changes from 10 commits
f21d573
4473149
67bb56f
f71e5c9
54919e3
fab2dde
1fe972f
9233a7c
23ab6cd
a55f54e
ecc66eb
bd92fe0
636684e
73ce076
0a13a19
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 |
---|---|---|
@@ -1,3 +1,145 @@ | ||
table: | ||
name: socrata_export_crashes_view | ||
schema: public | ||
select_permissions: | ||
- role: editor | ||
permission: | ||
columns: | ||
- bicycle_death_count | ||
- bicycle_serious_injury_count | ||
- death_cnt | ||
- law_enf_fatality_count | ||
- micromobility_death_count | ||
- micromobility_serious_injury_count | ||
- motorcycle_death_count | ||
- motorcycle_serious_injury_count | ||
- motor_vehicle_death_count | ||
- motor_vehicle_serious_injury_count | ||
- nonincap_injry_cnt | ||
- non_injry_cnt | ||
- other_death_count | ||
- other_serious_injury_count | ||
- pedestrian_death_count | ||
- pedestrian_serious_injury_count | ||
- poss_injry_cnt | ||
- sus_serious_injry_cnt | ||
- tot_injry_cnt | ||
- unkn_injry_cnt | ||
- years_of_life_lost | ||
- crash_fatal_fl | ||
- onsys_fl | ||
- private_dr_fl | ||
- road_constr_zone_fl | ||
- crash_id | ||
- crash_sev_id | ||
- crash_speed_limit | ||
- id | ||
- latitude | ||
- longitude | ||
- address_primary | ||
- address_secondary | ||
- case_id | ||
- crash_timestamp | ||
- crash_timestamp_ct | ||
- point | ||
- rpt_block_num | ||
- rpt_street_name | ||
- rpt_street_sfx | ||
- units_involved | ||
filter: {} | ||
allow_aggregations: true | ||
comment: "" | ||
- role: readonly | ||
permission: | ||
columns: | ||
- bicycle_death_count | ||
- bicycle_serious_injury_count | ||
- death_cnt | ||
- law_enf_fatality_count | ||
- micromobility_death_count | ||
- micromobility_serious_injury_count | ||
- motorcycle_death_count | ||
- motorcycle_serious_injury_count | ||
- motor_vehicle_death_count | ||
- motor_vehicle_serious_injury_count | ||
- nonincap_injry_cnt | ||
- non_injry_cnt | ||
- other_death_count | ||
- other_serious_injury_count | ||
- pedestrian_death_count | ||
- pedestrian_serious_injury_count | ||
- poss_injry_cnt | ||
- sus_serious_injry_cnt | ||
- tot_injry_cnt | ||
- unkn_injry_cnt | ||
- years_of_life_lost | ||
- crash_fatal_fl | ||
- onsys_fl | ||
- private_dr_fl | ||
- road_constr_zone_fl | ||
- crash_id | ||
- crash_sev_id | ||
- crash_speed_limit | ||
- id | ||
- latitude | ||
- longitude | ||
- address_primary | ||
- address_secondary | ||
- case_id | ||
- crash_timestamp | ||
- crash_timestamp_ct | ||
- point | ||
- rpt_block_num | ||
- rpt_street_name | ||
- rpt_street_sfx | ||
- units_involved | ||
filter: {} | ||
allow_aggregations: true | ||
comment: "" | ||
- role: vz-admin | ||
permission: | ||
columns: | ||
- bicycle_death_count | ||
- bicycle_serious_injury_count | ||
- death_cnt | ||
- law_enf_fatality_count | ||
- micromobility_death_count | ||
- micromobility_serious_injury_count | ||
- motorcycle_death_count | ||
- motorcycle_serious_injury_count | ||
- motor_vehicle_death_count | ||
- motor_vehicle_serious_injury_count | ||
- nonincap_injry_cnt | ||
- non_injry_cnt | ||
- other_death_count | ||
- other_serious_injury_count | ||
- pedestrian_death_count | ||
- pedestrian_serious_injury_count | ||
- poss_injry_cnt | ||
- sus_serious_injry_cnt | ||
- tot_injry_cnt | ||
- unkn_injry_cnt | ||
- years_of_life_lost | ||
- crash_fatal_fl | ||
- onsys_fl | ||
- private_dr_fl | ||
- road_constr_zone_fl | ||
- crash_id | ||
- crash_sev_id | ||
- crash_speed_limit | ||
- id | ||
- latitude | ||
- longitude | ||
- address_primary | ||
- address_secondary | ||
- case_id | ||
- crash_timestamp | ||
- crash_timestamp_ct | ||
- point | ||
- rpt_block_num | ||
- rpt_street_name | ||
- rpt_street_sfx | ||
- units_involved | ||
filter: {} | ||
allow_aggregations: true | ||
comment: "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,10 @@ import { | |
|
||
const GET_TEMP_RECORDS = gql` | ||
query getTempRecords { | ||
crashes(where: { is_temp_record: { _eq: true } }) { | ||
crashes( | ||
where: { is_temp_record: { _eq: true } } | ||
order_by: { record_locator: asc } | ||
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. was annoying me that the temp records table wasnt being sorted so it was hard to find ur last record creation 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. do you want to sort this by also, i could have sworn you had configured the query to refetch after form submit so that the temp records table gets refreshed. that's not happening anymore. maybe i broke that when i patched your branch?? 🙈 |
||
) { | ||
record_locator | ||
case_id | ||
crash_timestamp | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,41 +5,31 @@ import { useQuery } from "@apollo/react-hooks"; | |
import Widget02 from "../Widgets/Widget02"; | ||
import VZLinksWidget from "../Widgets/VZLinksWidget"; | ||
import VZNoticeWidget from "../Widgets/VZNoticeWidget"; | ||
import { format, subDays } from "date-fns"; | ||
import { subDays } from "date-fns"; | ||
|
||
import { GET_CRASHES_YTD } from "../../queries/dashboard"; | ||
|
||
import bi_logo from "../../assets/img/brand/power_bi_icon_white_on_transparent.png"; | ||
|
||
function VZDashboard() { | ||
const year = new Date().getFullYear(); | ||
const yearStart = `${year}-01-01`; | ||
const yearStart = `${year}-01-01T00:00:00`; | ||
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. little TZ bug here—to get the |
||
// We use the same end date as VZV so VZE widget totals match VZV widgets | ||
const yearEnd = format(subDays(new Date(), 14), "yyyy-MM-dd"); | ||
const yearEnd = subDays(new Date(), 14) | ||
.toISOString() | ||
.substring(0, 19); // to match the ISO string format in the socrata view crash_timestamp column | ||
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. we are creating a date in UTC time so that this is cross compatible with users in any time zone. cutting off the last milliseconds in the ISO string bc the 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 think you can do away 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. hah you're so right wow what a silly oversight on my part 😅 |
||
const { loading, error, data } = useQuery(GET_CRASHES_YTD, { | ||
variables: { yearStart, yearEnd }, | ||
}); | ||
|
||
if (loading) return "Loading..."; | ||
if (error) return `Error! ${error.message}`; | ||
|
||
const { | ||
years_of_life_lost: yearsOfLifeLostPrimaryPerson, | ||
} = data.primaryPersonFatalities.aggregate.sum; | ||
|
||
const { | ||
years_of_life_lost: yearsOfLifeLostPerson, | ||
} = data.personFatalities.aggregate.sum; | ||
|
||
const { | ||
sus_serious_injry_cnt: seriousInjuryCount, | ||
} = data.seriousInjuriesAndTotal.aggregate.sum; | ||
const { atd_fatality_count: deathCount } = data.fatalities.aggregate.sum; | ||
const aggregateData = | ||
data.socrata_export_crashes_view_aggregate.aggregate.sum; | ||
|
||
const yearsOfLifeLostYTD = | ||
yearsOfLifeLostPrimaryPerson + yearsOfLifeLostPerson; | ||
const fatalitiesYTD = deathCount; | ||
const seriousInjuriesYTD = seriousInjuryCount; | ||
const yearsOfLifeLostYTD = aggregateData.years_of_life_lost; | ||
const fatalitiesYTD = aggregateData.death_cnt; | ||
const seriousInjuriesYTD = aggregateData.sus_serious_injry_cnt; | ||
|
||
// Widget02 expects a string value, DB returns number or null | ||
const commaSeparator = 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.
lil typo 😄