Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix list edits not being correctly picked up by solr updater #9759

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions openlibrary/solr/update.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import logging
from pathlib import Path
from typing import Literal, cast
Expand Down Expand Up @@ -35,6 +36,23 @@
data_provider = cast(DataProvider, None)


@functools.cache
def get_solr_updaters() -> list[AbstractSolrUpdater]:
global data_provider
assert data_provider is not None
return [
# ORDER MATTERS
EditionSolrUpdater(data_provider),
WorkSolrUpdater(data_provider),
AuthorSolrUpdater(data_provider),
ListSolrUpdater(data_provider),
]


def can_update_key(key: str) -> bool:
return any(updater.key_test(key) for updater in get_solr_updaters())


async def update_keys(
keys: list[str],
commit=True,
Expand Down Expand Up @@ -69,15 +87,7 @@ def _solr_update(update_state: SolrUpdateRequest):

net_update = SolrUpdateRequest(commit=commit)

solr_updaters: list[AbstractSolrUpdater] = [
# ORDER MATTERS
EditionSolrUpdater(data_provider),
WorkSolrUpdater(data_provider),
AuthorSolrUpdater(data_provider),
ListSolrUpdater(data_provider),
]

for updater in solr_updaters:
for updater in get_solr_updaters():
update_state = SolrUpdateRequest(commit=commit)
updater_keys = uniq(k for k in keys if updater.key_test(k))
await updater.preload_keys(updater_keys)
Expand Down
6 changes: 1 addition & 5 deletions scripts/solr_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ async def update_keys(keys):
logger.debug("Args: %s" % str(args))
update.load_configs(args['ol_url'], args['ol_config'], 'default')

keys = [
k
for k in keys
if k.count("/") == 2 and k.split("/")[1] in ("books", "authors", "works")
]
keys = [k for k in keys if update.can_update_key(k)]

count = 0
for chunk in web.group(keys, 100):
Expand Down
Loading