Skip to content

Commit

Permalink
Merge pull request #2706 from data-for-change/2703-refactore-extract-…
Browse files Browse the repository at this point in the history
…geo-features-addition

remove update_cbs_location_only
  • Loading branch information
atalyaalon authored Sep 26, 2024
2 parents 0e9a621 + 0b8414f commit ba0d634
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions anyway/parsers/news_flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
news_flash_classifiers = {"ynet": classify_rss, "twitter": classify_tweets, "walla": classify_rss}


def update_all_in_db(source=None, newsflash_id=None, update_cbs_location_only=False):
def update_all_in_db(source=None, newsflash_id=None, use_existing_coordinates_only=False):
"""
main function for newsflash updating.
Expand All @@ -30,13 +30,15 @@ def update_all_in_db(source=None, newsflash_id=None, update_cbs_location_only=Fa
newsflash_items = db.get_all_newsflash()
for i, newsflash in enumerate(newsflash_items):
logging.debug(f"Updating news-flash:{newsflash.id}")
if not update_cbs_location_only:
if not use_existing_coordinates_only:
classify = news_flash_classifiers[newsflash.source]
newsflash.organization = classify_organization(newsflash.source)
newsflash.accident = classify(newsflash.title)
if newsflash.accident:
extract_geo_features(
db=db, newsflash=newsflash, use_existing_coordinates_only=update_cbs_location_only
db=db,
newsflash=newsflash,
use_existing_coordinates_only=use_existing_coordinates_only,
)
if i % 1000 == 0:
db.commit()
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ def update_news_flash():
@update_news_flash.command()
@click.option("--source", default="", type=str)
@click.option("--news_flash_id", default="", type=str)
@click.option("--update_cbs_location_only", is_flag=True)
def update(source, news_flash_id, update_cbs_location_only):
@click.option("--use_existing_coordinates_only", is_flag=True)
def update(source, news_flash_id, use_existing_coordinates_only):
from anyway.parsers import news_flash

if not source:
source = None
if not news_flash_id:
news_flash_id = None
return news_flash.update_all_in_db(source, news_flash_id, update_cbs_location_only)
return news_flash.update_all_in_db(source, news_flash_id, use_existing_coordinates_only)


@update_news_flash.command()
Expand Down

0 comments on commit ba0d634

Please sign in to comment.