From 9a05ba38b8c1ed1c4ce7de86211da188ea34b75b Mon Sep 17 00:00:00 2001 From: Cesar Date: Fri, 23 Feb 2024 02:12:51 +0100 Subject: [PATCH] chore: get twitter info from get projects lightweight --- workers/fund_public_goods/db/tables/projects.py | 2 +- workers/fund_public_goods/lib/strategy/utils/utils.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/workers/fund_public_goods/db/tables/projects.py b/workers/fund_public_goods/db/tables/projects.py index f7e5e95..64f4911 100644 --- a/workers/fund_public_goods/db/tables/projects.py +++ b/workers/fund_public_goods/db/tables/projects.py @@ -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() diff --git a/workers/fund_public_goods/lib/strategy/utils/utils.py b/workers/fund_public_goods/lib/strategy/utils/utils.py index c8484a3..551272e 100644 --- a/workers/fund_public_goods/lib/strategy/utils/utils.py +++ b/workers/fund_public_goods/lib/strategy/utils/utils.py @@ -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())