Skip to content

Commit b0dbb59

Browse files
committed
add logic for R == 4...
...in _parse_vaccinations_by_day() There was no case yet for R == 4 but it's the only missing permutation.
1 parent 4278f6b commit b0dbb59

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

cepimose/parser.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _parse_vaccinations_by_day(data) -> "list[VaccinationByDayRow]":
3939
resp = data["results"][0]["result"]["data"]["dsr"]["DS"][0]["PH"][0]["DM0"]
4040
parsed_data: "list[VaccinationByDayRow]" = []
4141

42-
r_list = [None, 2, 6, 8, 10, 12, 14]
42+
r_list = [None, 2, 4, 6, 8, 10, 12, 14]
4343

4444
date = None
4545
people_vaccinated = None
@@ -52,40 +52,52 @@ def _parse_vaccinations_by_day(data) -> "list[VaccinationByDayRow]":
5252
date = parse_date(C[0])
5353

5454
if R not in r_list:
55-
print(date, R, C, sep="\t")
56-
raise Exception("Unknown R value!")
55+
raise Exception(f"Unknown R: {R}, date: {date}, C: {C}!")
5756

5857
if R == None:
5958
people_vaccinated = C[1]
6059
people_fully_vaccinated = C[2]
6160
people_third_dose = C[3]
6261

62+
# reuse from previous iteration
6363
if R == 2:
64+
# reuse first dose
6465
people_vaccinated = parsed_data[-1].first_dose
6566
people_fully_vaccinated = C[1]
6667
people_third_dose = C[2]
6768

69+
if R == 4:
70+
# reuse second dose
71+
people_vaccinated = C[1]
72+
people_fully_vaccinated = parsed_data[-1].second_dose
73+
people_third_dose = C[2]
74+
6875
if R == 6:
76+
# reuse first and second dose
6977
people_vaccinated = parsed_data[-1].first_dose
7078
people_fully_vaccinated = parsed_data[-1].second_dose
7179
people_third_dose = C[1]
7280

7381
if R == 8:
82+
# reuse third dose
7483
people_vaccinated = C[1]
7584
people_fully_vaccinated = C[2]
7685
people_third_dose = parsed_data[-1].third_dose
7786

7887
if R == 10:
88+
# reuse first and third dose
7989
people_vaccinated = parsed_data[-1].first_dose
8090
people_fully_vaccinated = C[1]
8191
people_third_dose = parsed_data[-1].third_dose
8292

8393
if R == 12:
94+
# reuse second and third dose
8495
people_vaccinated = C[1]
8596
people_fully_vaccinated = parsed_data[-1].second_dose
8697
people_third_dose = parsed_data[-1].third_dose
8798

8899
if R == 14:
100+
# reuse all doses
89101
people_vaccinated = parsed_data[-1].first_dose
90102
people_fully_vaccinated = parsed_data[-1].second_dose
91103
people_third_dose = parsed_data[-1].third_dose

0 commit comments

Comments
 (0)