Skip to content

Commit

Permalink
tasks: update create logs
Browse files Browse the repository at this point in the history
Signed-off-by: pamfilos <[email protected]>
  • Loading branch information
pamfilos committed Nov 11, 2024
1 parent fdcad6d commit 0039d52
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions scoap3/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ def _create_author_identifier(data, authors):

def _create_country(affiliation):
country = affiliation.get("country", "")
logger.info("Creating country:%s for affiliation:%s", country, affiliation)
try:
if not country or country == "HUMAN CHECK":
return None
Expand Down Expand Up @@ -338,10 +337,9 @@ def _create_country(affiliation):
"code": cc.convert(country, to="iso2"),
"name": cc.convert(country, to="name_short"),
}
country_obj, existed = Country.objects.get_or_create(**country_data)
logger.info(
"Country:%s %s.", country_obj.name, "created" if not existed else "updated"
)
country_obj, created = Country.objects.get_or_create(**country_data)
if created:
logger.info("Created country:%s for affiliation:%s", country, affiliation)
return country_obj
except LookupError as e:
capture_exception(e)
Expand All @@ -358,19 +356,17 @@ def _create_affiliation(data, authors):
"value": affiliation.get("value", ""),
"organization": affiliation.get("organization", ""),
}
logger.info(
"Created country:%s for author:%s affiliation:%s",
country.name if country else "No Country",
author.get("full_name", "No author name"),
affiliation.get("value", "No affiliation value"),
)
try:
affiliation, _ = Affiliation.objects.get_or_create(**affiliation_data)
affiliation.author_id.add(authors[idx].id)
affiliations.append(affiliation)

except MultipleObjectsReturned:
print(affiliation_data)
logger.error(
"While creating author:%s affiliation:%s",
author.get("full_name", "No author name"),
affiliation.get("value", "No affiliation value"),
)
return affiliations


Expand Down

0 comments on commit 0039d52

Please sign in to comment.