Skip to content

Commit

Permalink
Exclude bikeracks from projects
Browse files Browse the repository at this point in the history
They are not of interest for now.
  • Loading branch information
phansch committed Sep 16, 2024
1 parent ebde728 commit 8295216
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions sync/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ class ProjectState(Enum):
IN_PLANNING = "in Planung"
ENVISAGED = "Vorgesehen"


def is_project_to_scrape(project):
return without_done_projects(project) and without_bike_racks(project)


def without_done_projects(project):
return project['status'] != ProjectState.DONE.value

def without_bike_racks(project):
return project['types'][0]['type'] == 'Anlehnb\u00fcgel'

def project_slug_from_url(project_url):
return project_url.split('/')[-2]

Expand Down
2 changes: 1 addition & 1 deletion sync/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def run():
print(f"Downloaded {len(all_projects)} projects from the Infravelo API")

# Select projects that are not finished yet, to avoid needless scraping
projects_to_scrape = list(filter(core.without_done_projects, all_projects))
projects_to_scrape = list(filter(core.is_project_to_scrape, all_projects))
print(f"About to scrape {len(projects_to_scrape)} projects.")

core.create_project_dirs(projects_to_scrape)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ def test_filter():
result = list(filter(core.without_done_projects, p1))
assert result == [{ 'status': 'in Bau'}]

def test_bike_rack_filter():
p1 = [{ "types": [{"name": "", "type": "Anlehnb\u00fcgel", "metrics": [{"name": "Anzahl Stellpl\u00e4tze", "value": "16"}]}] }]
result = list(filter(core.without_bike_racks))

def test_project_slug_from_url():
url = "https://www.example.com/projekt/oderberger-strasse-8/"
Expand Down

0 comments on commit 8295216

Please sign in to comment.