Skip to content

Commit

Permalink
Modif report (#257)
Browse files Browse the repository at this point in the history
* correctBruit_AddEur6

* remove unnecessary comments

* typo

* Rename SPCH-13 to SPCH13 in basedata and tests too

* Fix formatting

* Enable ci tests for PR too

Co-authored-by: Mario Baranzini <[email protected]>
  • Loading branch information
spch-GL and marioba authored Jun 27, 2022
1 parent 8c1ac1c commit 8c00c9a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
branches:
- '*'

# pull_request:
# branches:
# - master
pull_request:
branches:
- master

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion comptages/basedata/class.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ id,name,description
"22",ARX Cycle,Vélos seul
"13",FHWA13,Federal HighWay Administration 13 category
"14",SWISS7-MM,SWISS 7 modified for Marksmann devices
"15",SPCH-13,SPCH-13
"15",SPCH13,SPCH13
"16",SPCH-MD 5C,SPCH-MD 5C
57 changes: 36 additions & 21 deletions comptages/core/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def _data_count(count, section, monday, workbook):
)
ws['B7'] = 'Modèle : {}'.format(
count.id_model.name)
ws['B8'] = 'Classification : {}'.format(
_t_cl(count.id_class.name))
ws['B8'] = 'Classification : {}'.format(count.id_class.name)

ws['B9'] = 'Comptage véhicule par véhicule'
if _is_aggregate(count):
Expand Down Expand Up @@ -173,22 +172,19 @@ def _data_count_yearly(count, section, year, workbook):
int(section.end_dist)
)

ws['B4'] = 'Periode de comptage du 01/01/{0} au 31/12/{0}'.format(
year)
ws['B4'] = 'Periode de comptage du 01/01/{0} au 31/12/{0}'.format(year)

ws['B5'] = 'Comptage {}'.format(year)

ws['B6'] = 'Type de capteur : {}'.format(
count.id_sensor_type.name
)
ws['B7'] = 'Modèle : {}'.format(
count.id_model.name)
ws['B8'] = 'Classification : {}'.format(
_t_cl(count.id_class.name))
ws['B6'] = 'Type de capteur : {}'.format(count.id_sensor_type.name)

ws['B7'] = 'Modèle : {}'.format(count.id_model.name)

ws['B8'] = 'Classification : {}'.format(count.id_class.name)

ws['B9'] = 'Comptage véhicule par véhicule'
if _is_aggregate(count):
ws['B9'] = 'Comptage par interval'
ws['B9'] = 'Comptage par intervale'

ws['B11'] = section.place_name

Expand Down Expand Up @@ -874,14 +870,25 @@ def _remove_useless_sheets(count, workbook):
if class_name == 'SWISS10':
workbook.remove_sheet(workbook['SWISS7_H'])
workbook.remove_sheet(workbook['SWISS7_G'])
workbook.remove_sheet(workbook['EUR6_H'])
workbook.remove_sheet(workbook['EUR6_G'])
elif class_name == 'SWISS7':
workbook.remove_sheet(workbook['SWISS10_H'])
workbook.remove_sheet(workbook['SWISS10_G'])
workbook.remove_sheet(workbook['EUR6_H'])
workbook.remove_sheet(workbook['EUR6_G'])
elif class_name == 'EUR6':
workbook.remove_sheet(workbook['SWISS10_H'])
workbook.remove_sheet(workbook['SWISS10_G'])
workbook.remove_sheet(workbook['SWISS7_H'])
workbook.remove_sheet(workbook['SWISS7_G'])
elif class_name == 'Volume':
workbook.remove_sheet(workbook['SWISS7_H'])
workbook.remove_sheet(workbook['SWISS7_G'])
workbook.remove_sheet(workbook['SWISS10_H'])
workbook.remove_sheet(workbook['SWISS10_G'])
workbook.remove_sheet(workbook['EUR6_H'])
workbook.remove_sheet(workbook['EUR6_G'])

if _is_aggregate(count):
workbook.remove_sheet(workbook['Vit_Hd'])
Expand All @@ -898,7 +905,7 @@ def _t_cl(class_name):
if class_name is None:
return 'Volume'

if class_name == 'SPCH-13':
if class_name == 'SPCH13':
return 'SWISS7'

return class_name
Expand All @@ -910,12 +917,6 @@ def _t_cat(count, cat_id):
report cells
"""

if count.id_class.name == 'SWISS10':
return cat_id

if count.id_class.name == 'SWISS7':
return cat_id

if count.id_class.name == 'ARX Cycle':
# FIXME: implement real conversiont between ARX Cycle and SWISS7 or 10
new_hour = [0] * 7
Expand All @@ -941,7 +942,7 @@ def _t_cat(count, cat_id):
}
return conv[cat_id]

if count.id_class.name == 'SPCH-13':
if count.id_class.name == 'SPCH13':
conv = {
0: 0,
1: 2,
Expand All @@ -954,12 +955,26 @@ def _t_cat(count, cat_id):
8: 5,
9: 6,
10: 7,
11: 7,
11: 6,
12: 6,
13: 7,
}
return conv[cat_id]

if count.id_class.name == 'EUR6':
conv = {
0: 0,
1: 2,
2: 3,
3: 4,
4: 5,
5: 6,
6: 1,
}
return conv[cat_id]

return cat_id if cat_id < 11 else 10


def _is_aggregate(count):
from_aggregate = models. \
Expand Down
Binary file modified comptages/report/template.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion comptages/test/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_import_mc(self):
model = models.Model.objects.all()[0]
device = models.Device.objects.all()[0]
sensor_type = models.SensorType.objects.all()[0]
class_ = models.Class.objects.get(name="SPCH-13")
class_ = models.Class.objects.get(name="SPCH13")
installation = models.Installation.objects.get(name="64210836")

count = models.Count.objects.create(
Expand Down
6 changes: 3 additions & 3 deletions db/domain_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ INSERT INTO comptages.class VALUES (21, 'Bicycle', 'Vélos seul');
INSERT INTO comptages.class VALUES (22, 'ARX Cycle', 'Vélos seul');
INSERT INTO comptages.class VALUES (13, 'FHWA13', 'Federal HighWay Administration 13 category');
INSERT INTO comptages.class VALUES (14, 'SWISS7-MM', 'SWISS 7 modified for Marksmann devices');
INSERT INTO comptages.class VALUES (15, 'SPCH-13', 'SPCH-13');
INSERT INTO comptages.class VALUES (15, 'SPCH13', 'SPCH13');
INSERT INTO comptages.class VALUES (16, 'SPCH-MD 5C', 'SPCH-MD 5C');

-- category
Expand Down Expand Up @@ -124,7 +124,7 @@ INSERT INTO comptages.category (id, name, code, id_category, light) VALUES (84,
INSERT INTO comptages.category (id, name, code, id_category, light) VALUES (85, 'SZ', 6, 2, FALSE);
INSERT INTO comptages.category (id, name, code, id_category, light) VALUES (86, 'MR', 7, 2, TRUE);

-- SPCH-13
-- SPCH13
INSERT INTO comptages.category (id, name, code, id_category, light) VALUES (87, 'TRASH', 0, 2, TRUE);
INSERT INTO comptages.category (id, name, code, id_category, light) VALUES (88, 'CAR', 1, 2, FALSE);
INSERT INTO comptages.category (id, name, code, id_category, light) VALUES (89, 'MR', 2, 2, TRUE);
Expand Down Expand Up @@ -255,7 +255,7 @@ INSERT INTO comptages.class_category (id_class, id_category) VALUES (14, 84);
INSERT INTO comptages.class_category (id_class, id_category) VALUES (14, 85);
INSERT INTO comptages.class_category (id_class, id_category) VALUES (14, 86);

-- SPCH-13
-- SPCH13
INSERT INTO comptages.class_category (id_class, id_category) VALUES (15, 87);
INSERT INTO comptages.class_category (id_class, id_category) VALUES (15, 88);
INSERT INTO comptages.class_category (id_class, id_category) VALUES (15, 89);
Expand Down

0 comments on commit 8c00c9a

Please sign in to comment.