diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13ae3ac8..db12ed82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,9 @@ on: branches: - '*' - # pull_request: - # branches: - # - master + pull_request: + branches: + - master jobs: test: diff --git a/comptages/basedata/class.csv b/comptages/basedata/class.csv index c86288ad..5775e862 100644 --- a/comptages/basedata/class.csv +++ b/comptages/basedata/class.csv @@ -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 diff --git a/comptages/core/report.py b/comptages/core/report.py index 8e1efb5e..52e387fe 100644 --- a/comptages/core/report.py +++ b/comptages/core/report.py @@ -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): @@ -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 @@ -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']) @@ -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 @@ -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 @@ -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, @@ -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. \ diff --git a/comptages/report/template.xlsx b/comptages/report/template.xlsx index 2fb0abb6..efa77013 100644 Binary files a/comptages/report/template.xlsx and b/comptages/report/template.xlsx differ diff --git a/comptages/test/test_import.py b/comptages/test/test_import.py index ccc3b889..1392e580 100644 --- a/comptages/test/test_import.py +++ b/comptages/test/test_import.py @@ -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( diff --git a/db/domain_data.sql b/db/domain_data.sql index 91e6d6cd..6596b0ba 100644 --- a/db/domain_data.sql +++ b/db/domain_data.sql @@ -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 @@ -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); @@ -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);