Skip to content

Commit

Permalink
[fix] webscraper merge function now starts looking for numbers starti…
Browse files Browse the repository at this point in the history
…ng from the end
  • Loading branch information
deenasun committed Jan 16, 2025
1 parent aa917bf commit 6fa6239
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Binary file modified api/webscraper/__pycache__/nyserda_scraper.cpython-312.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion api/webscraper/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ def merge_projects():
# otherwise, combine fields of current project with duplicate's data
update = combine_projects(update, matching_project)

# add sizes of duplicate proejcts together
# add sizes of duplicate projects together
if (
update.get("size", None) is not None
and matching_project.get("size", None) is not None
Expand Down
15 changes: 8 additions & 7 deletions api/webscraper/utils/scraper_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,14 @@ def find_keyword(project_name):
i = project_name.lower().find("wind")
return project_name[:i].strip()
else:
j = 0
while j < len(project_name):
if project_name[j].isdigit():
break
else:
j += 1
return project_name[:j].strip()
last_non_digit_index = len(project_name) - 1
while last_non_digit_index > 0 and project_name[last_non_digit_index].isdigit():
last_non_digit_index -= 1
return (
project_name[: last_non_digit_index + 1].strip()
if last_non_digit_index < len(project_name) - 1
else project_name.strip()
)


def combine_projects(existing_project: dict, new_project: dict) -> dict:
Expand Down

0 comments on commit 6fa6239

Please sign in to comment.