data-for-change / anyway

ANYWAY - Car accidents map
http://www.anyway.co.il
MIT License
77 stars 242 forks source link

Widget: Motorcycle_accidents_type_-_road_20_vs_all_roads #1606

Open MichalOren opened 3 years ago

MichalOren commented 3 years ago

Name Query for: most common motorcycle accidents types in a specific road vs all other interurban roads. Most common refer to the top 5 accidents types in the current road (in our case road 20)

Title סוגי תאונות אופנועים בכביש __ בהשוואה לכל הארץ (שם הכותרת משתנה כתלות במספר כביש)

Visualization image

Visualization explanation Visualization contains 5 bars on etch side, we refer as ‘butterfly graph’. for a specific road and for all of Israel interurban roads. Bars is will not completing to 100%. Etch one displaying the percentage of accidents by type with motorcycles vs all other interurban roads.

Use case This infographic should be displayed – when motorcycle is involved/mention in the newsflash

SQL query See query here Road number changes - according to the newsflash road1 field. Time frame: 2014-2019 Vehicle type changes - according to the newsflash (find definition below)

Additional context Add accidents involving other vehicle types--> replace "vehicle_type IN (8,9,10,19)" : Bus: vehicle_type IN (11,18) Train: vehicle_type IN (16) Tractor: vehicle_type IN (14) Private car: vehicle_type IN (1,12) Trucks: vehicle_type IN (4,5,6,7,24,25) Tracks category does not include medium vehicle type like Van\Tender\Transit

atalyaalon commented 3 years ago

@rsperer we want to create multiple similar widgets - each one with different vehicle type. We want each widget to have a unique id - maybe we can use class inheritance here? Perhaps @ziv17 you have an idea what's the best way to model this?

ziv17 commented 3 years ago

Is it exactly same widget, but for different vehicle type? Or with small differences?

atalyaalon commented 3 years ago

@ziv17 yes it's exactly the same widget but with different vehicle types

ziv17 commented 3 years ago

I would use a @classmethod as a factory to generate the widget instances. One at Widget class for all the regular cases, and one for this widget, were it will generate an instance for each vehicle. I can do the infrastructure part if you prefer.

rsperer commented 3 years ago

I'd like to tackle it myself, will consult @ziv17 about the class infrastructure

MichalOren commented 3 years ago

sorry i did not mean to cose it ):

rsperer commented 3 years ago

@MichalOren I see that the query returns accident_type as int but the visualization shows it as string. What should it be?

rsperer commented 3 years ago

@MichalOren @atalyaalon I see all other infographics extract from "involved_markers_hebrew" while this one goes to "markers". Wanted to verify with you this is indeed what we want.

rsperer commented 3 years ago

@ziv17 yes it's exactly the same widget but with different vehicle types

@atalyaalon do we expect to generate all those widgets when returning data per a specific news_flash or I we likely to generate just one\two depending on the vehicle(s) involved?

atalyaalon commented 3 years ago

@MichalOren I see that the query returns accident_type as int but the visualization shows it as string. What should it be?

return accident_type and use the english_accident_type_dict as used here

atalyaalon commented 3 years ago

@MichalOren @atalyaalon I see all other infographics extract from "involved_markers_hebrew" while this one goes to "markers". Wanted to verify with you this is indeed what we want.

Yes, in this widget we count accidents, using markers is enough

atalyaalon commented 3 years ago

@ziv17 yes it's exactly the same widget but with different vehicle types

@atalyaalon do we expect to generate all those widgets when returning data per a specific news_flash or I we likely to generate just one\two depending on the vehicle(s) involved?

We might generate more than one widget - we don't want to be limited in that sense and have the option to send all of the Widgets with different vehicle types.

rsperer commented 3 years ago

@atalyaalon @MichalOren I have a question about how we should retrieve "last 5 years". The referenced query uses field accident_year and values (2014,2019) while in most queries we look at last 5 years ranging back from the accident date. Which one should it be for this query? For now I did the latter (like other queries)

MichalOren commented 3 years ago

OK by me

atalyaalon commented 3 years ago

@rsperer closing this one

atalyaalon commented 3 years ago

@rsperer can you create a FE issue now that API exists?

atalyaalon commented 3 years ago

Similar to this one - https://github.com/hasadna/anyway-newsflash-infographics/issues/541 With the visualization @MichalOren created