Skip to content

Commit

Permalink
Ecoharmonogram: Gather cumulative entries, no duplicates. (#2188)
Browse files Browse the repository at this point in the history
Co-authored-by: prudy <prudy@protonmail.com>
  • Loading branch information
prudy and prudy authored Jun 25, 2024
1 parent 2988bb9 commit 96ba1d2
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ def fetch(self):
entries.extend(self._create_entries(sp, town))
return entries

def _entry_exists(self, dmy, name, entries: [Collection]):
for e in entries:
if dmy == e.date and name == e.type:
return True
return False

def _create_entries(self, sp, town):
streets = Ecoharmonogram.fetch_streets(
sp, town, self.street_input, self.house_number_input
Expand Down Expand Up @@ -157,18 +163,17 @@ def _create_entries(self, sp, town):
z["name"] = get.get("name")
schedules.append(z)

entries = []
for sch in schedules:
days = sch.get("days").split(";")
month = sch.get("month")
year = sch.get("year")
for d in days:
entries.append(
Collection(
datetime.date(int(year), int(month), int(d)),
sch.get("name"),
dmy = datetime.date(int(year), int(month), int(d))
name = sch.get("name")
if not self._entry_exists(dmy, name, entries):
entries.append(
Collection(dmy, name)
)
)
if self.additional_sides_matcher_input != "":
return entries
return entries

0 comments on commit 96ba1d2

Please sign in to comment.