Skip to content

Commit

Permalink
chore: get twitter info from get projects lightweight
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrzn committed Feb 23, 2024
1 parent 386096d commit 9a05ba3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion workers/fund_public_goods/db/tables/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_projects_lightweight(range_from: int, range_to: int) -> PostgrestAPIResp
return (
db.table("projects")
.select(
"id, title, website, updated_at, description"
"id, title, website, updated_at, description, twitter"
)
.range(range_from, range_to)
.execute()
Expand Down
7 changes: 3 additions & 4 deletions workers/fund_public_goods/lib/strategy/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ def get_latest_project_per_website(projects: list[Projects]) -> list[Projects]:
projects_with_website_as_key[project_website] = project

projects_with_twitter_handle_as_key: dict[str, Projects] = {}

for (webstite, project) in projects_with_website_as_key.items():
for (website, project) in projects_with_website_as_key.items():
if project.twitter:
if (project.twitter not in projects_with_twitter_handle_as_key or project.updated_at > projects_with_website_as_key[project_website].updated_at):
if (project.twitter not in projects_with_twitter_handle_as_key):
projects_with_twitter_handle_as_key[project.twitter] = project
else:
projects_with_twitter_handle_as_key[webstite] = project
projects_with_twitter_handle_as_key[website] = project

return list(projects_with_twitter_handle_as_key.values())

Expand Down

0 comments on commit 9a05ba3

Please sign in to comment.