Skip to content

Commit

Permalink
exclude trash 2, correction template
Browse files Browse the repository at this point in the history
  • Loading branch information
spch-GL committed Jun 4, 2024
1 parent f9ac9cb commit 5eb9284
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 94 deletions.
96 changes: 80 additions & 16 deletions comptages/core/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ def _data_count_yearly(
ws["B14"] = lanes[1].direction_desc


def _data_day(count: models.Count, section: models.Section, monday, workbook: Workbook):
def _data_day(
count: models.Count,
section: models.Section,
monday,
workbook: Workbook
):
ws = workbook["Data_day"]

# Monthly coefficients
Expand Down Expand Up @@ -353,15 +358,22 @@ def _data_day(count: models.Count, section: models.Section, monday, workbook: Wo


def _data_day_yearly(
count: models.Count, section: models.Section, year: int, workbook: Workbook
):
count: models.Count,
section: models.Section,
year: int,
workbook: Workbook
):
ws = workbook["Data_day"]

# Total (section)
row_offset = 69
col_offset = 2

df = statistics.get_time_data_yearly(year, section)
df = statistics.get_time_data_yearly(
year,
section,
exclude_trash=True,
)

if df is None:
print(f"{datetime.now()}:_data_day_yearly - Pas de données pour cette section {section} et cette année {year} /!\\/!\\/!\\")
Expand All @@ -376,7 +388,10 @@ def _data_day_yearly(
row_offset = 95
col_offset = 2
df = statistics.get_light_numbers_yearly(
section, start=datetime(year, 1, 1), end=datetime(year + 1, 1, 1)
section,
start=datetime(year, 1, 1),
end=datetime(year + 1, 1, 1),
exclude_trash=True,
)

for i in range(7):
Expand All @@ -395,9 +410,15 @@ def _data_day_yearly(
row_offset = 5
col_offset = 2

df = statistics.get_time_data_yearly(year, section, direction=1)
df = statistics.get_time_data_yearly(
year,
section,
direction=1,
exclude_trash=True,
)

if df is None:
print(f"{datetime.now()}:_data_day_yearly - Pas de données pour cette section:{section}, cette direction:{direction} et cette année:{year} /!\\/!\\/!\\")
return

for i in range(7):
Expand All @@ -409,7 +430,11 @@ def _data_day_yearly(
row_offset = 31
col_offset = 2
df = statistics.get_light_numbers_yearly(
section, start=datetime(year, 1, 1), end=datetime(year + 1, 1, 1), direction=1
section,
start=datetime(year, 1, 1),
end=datetime(year + 1, 1, 1),
direction=1,
exclude_trash=True,
)

for i in range(7):
Expand All @@ -429,7 +454,12 @@ def _data_day_yearly(
row_offset = 37
col_offset = 2

df = statistics.get_time_data_yearly(year, section, direction=2)
df = statistics.get_time_data_yearly(
year,
section,
direction=2,
exclude_trash=True,
)

for i in range(7):
day_df = df[df["date"] == i]
Expand All @@ -444,6 +474,7 @@ def _data_day_yearly(
start=datetime(year, 1, 1),
end=datetime(year + 1, 1, 1),
direction=2,
exclude_trash=True,
)

for i in range(7):
Expand All @@ -467,7 +498,12 @@ def _data_month_yearly(
end = datetime(year + 1, 1, 1)

# Section
df = statistics.get_month_data(section, start, end)
df = statistics.get_month_data(
section,
start,
end,
exclude_trash=True,
)

row_offset = 14
col_offset = 2
Expand All @@ -476,7 +512,13 @@ def _data_month_yearly(
ws.cell(row=row_offset, column=col_offset + col.Index, value=col.tm)

# Direction 1
df = statistics.get_month_data(section, start, end, direction=1)
df = statistics.get_month_data(
section,
start,
end,
direction=1,
exclude_trash=True,
)

row_offset = 4
col_offset = 2
Expand All @@ -485,7 +527,13 @@ def _data_month_yearly(
ws.cell(row=row_offset, column=col_offset + col.Index, value=col.tm)

# Direction 2
df = statistics.get_month_data(section, start, end, direction=2)
df = statistics.get_month_data(
section,
start,
end,
direction=2,
exclude_trash=True,
)

row_offset = 9
col_offset = 2
Expand Down Expand Up @@ -720,6 +768,7 @@ def _data_speed_yearly(
end=end,
speed_low=range_[0],
speed_high=range_[1],
exclude_trash=True,
)

for row in res:
Expand All @@ -731,7 +780,13 @@ def _data_speed_yearly(
col_offset = 16
for i, v in enumerate(characteristic_speeds):
df = statistics.get_characteristic_speed_by_hour(
None, section, direction=1, start=start, end=end, v=v
None,
section,
direction=1,
start=start,
end=end,
v=v,
exclude_trash=True,
)
for row in df.itertuples():
ws.cell(
Expand All @@ -743,11 +798,12 @@ def _data_speed_yearly(
col_offset = 19

df = statistics.get_average_speed_by_hour(
count,
None,
section,
direction=1,
start=start,
end=end,
exclude_trash=True,
)
for row in df.itertuples():
ws.cell(row=row_offset + row.Index, column=col_offset, value=row.speed)
Expand All @@ -758,13 +814,14 @@ def _data_speed_yearly(
col_offset = 2
for i, range_ in enumerate(speed_ranges):
res = statistics.get_speed_data_by_hour(
count,
None,
section,
direction=2,
start=start,
end=end,
speed_low=range_[0],
speed_high=range_[1],
exclude_trash=True,
)

for row in res:
Expand All @@ -776,7 +833,13 @@ def _data_speed_yearly(
col_offset = 16
for i, v in enumerate(characteristic_speeds):
df = statistics.get_characteristic_speed_by_hour(
count, section, direction=2, start=start, end=end, v=v
None,
section,
direction=2,
start=start,
end=end,
v=v,
exclude_trash=True,
)
for row in df.itertuples():
ws.cell(
Expand All @@ -790,11 +853,12 @@ def _data_speed_yearly(
col_offset = 19

df = statistics.get_average_speed_by_hour(
count,
None,
section,
direction=2,
start=start,
end=end,
exclude_trash=True,
)
for row in df.itertuples():
ws.cell(row=row_offset + row.Index, column=col_offset, value=row.speed)
Expand Down
Loading

0 comments on commit 5eb9284

Please sign in to comment.