Skip to content

Commit

Permalink
add rogue scholar posts to commonmeta
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Apr 9, 2024
1 parent ebcbf98 commit 2eb4444
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions api/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ async def extract_all_posts_by_blog(
async with httpx.AsyncClient() as client:
response = await client.get(feed_url, follow_redirects=True)
json = response.json()
print(py_.get(json, "pagination.nextPageOffset", None))
posts = json.get("items", [])
# only include posts that have been modified since last update
if not update_all:
Expand Down Expand Up @@ -950,8 +949,6 @@ def format_author(author, published_at):
async def update_rogue_scholar_post(post, blog):
"""Update Rogue Scholar post."""
try:
print(post)

def format_author(author, published_at):
"""Format author. Optionally lookup real name from username,
and ORCID from name."""
Expand Down Expand Up @@ -998,6 +995,11 @@ def format_author(author, published_at):
if i not in EXCLUDED_TAGS
]
tags = py_.uniq(tags)[:5]

# upsert post into works table if it has a DOI
if post.get("doi", None):
work = await get_single_work(post.get("doi"))
print("Work added to works table:", work.get("id", None))

return {
"authors": authors,
Expand Down
2 changes: 1 addition & 1 deletion api/works.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def get_single_work(string: str) -> Optional[dict]:
# rename pid to id and remove fields that are not part of the commonmeta schema
response = vars(response)
response = py_.rename_keys(response, {"pid": "id"})
response = py_.omit(response, "pid", "created", "updated")
response = py_.omit(response, "pid", "created", "updated", "collectionId", "collectionName")
return compact(response)


Expand Down

0 comments on commit 2eb4444

Please sign in to comment.