Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/tkalir/anyway into 2669-Impr…
Browse files Browse the repository at this point in the history
…ove-location-accuracy-for-street-newsflashes

# Conflicts:
#	main.py
  • Loading branch information
tkalir committed Oct 3, 2024
2 parents 135ce08 + ba0d634 commit eb374ca
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, False)
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 eb374ca

Please sign in to comment.