Numline1
08/29/2022, 6:20 PMKhuyen Tran
08/29/2022, 6:21 PMNumline1
08/29/2022, 6:22 PMSerina
08/29/2022, 6:22 PMNumline1
08/29/2022, 6:23 PM### Flows
@flow
def collect_stats_by_politician(since):
a = get_interactions_by_politician(since)
b = get_ads_spendings_by_politician(since, wait_for=[a])
@flow
def collect_stats_by_political_party(since):
a = get_interactions_by_political_party(since)
b = get_ads_spendings_by_political_party(since, wait_for=[a])
@flow
def collect_political_stats(days):
since = datetime.today() - timedelta(days=days)
clear_politicians_stats(since, 'interactions')
clear_politicians_stats(since, 'ads_spendings')
collect_stats_by_politician(since)
clear_political_parties_stats(since, 'interactions')
clear_political_parties_stats(since, 'ads_spendings')
collect_stats_by_political_party(since)
load_dotenv()
argument_list = sys.argv[1:]
options = "hmo:"
long_options = ["days="]
arguments, values = getopt.getopt(argument_list, options, long_options)
days = [item for item in arguments if item[0] == '--days']
collect_political_stats(int(days[0][1]) if len(days) else 3)
source /home/prefect/prefect_venv/bin/activate && prefect deployment build /home/prefect/flows/politicssocial/collect_political_stats.py:collect_political_stats -n politicssocial_collect_political_stats -q politicssocial
prefect 344495 50115 0 Aug27 ? 00:00:03 /home/prefect/prefect_venv/bin/python /home/prefect/prefect_venv/bin/prefect orion start
prefect 344519 344495 0 Aug27 ? 00:21:19 /home/prefect/prefect_venv/bin/python /home/prefect/prefect_venv/bin/uvicorn --factory prefect.orion.api.server:create_app --host 127.0.0.1 --port 4200
prefect 344561 50115 0 Aug27 ? 00:06:25 /home/prefect/prefect_venv/bin/python /home/prefect/prefect_venv/bin/prefect agent start -q politicssocial
Khuyen Tran
08/29/2022, 7:35 PM