Skip to content

Commit

Permalink
improves wikidata sync
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Jun 6, 2024
1 parent 9ccafaa commit 8cc15bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions ceurws/wikidata_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from ngwidgets.lod_grid import ListOfDictsGrid
from nicegui import ui
from nicegui import ui,run
from wd.query_view import QueryView

from ceurws.view import View
Expand Down Expand Up @@ -70,12 +70,13 @@ def reload_aggrid(self, olod: list):
itemLink = self.createItemLink(row, "item")
eventLink = self.createItemLink(row, "event", separator="|")
eventSeriesLink = self.createItemLink(row, "eventSeries", separator="|")
dblpLink = self.createExternalLink(row, "dblpProceedingsId", "dblp", DblpEndpoint.DBLP_REC_PREFIX)
dblpLink = self.createExternalLink(row, "dblpProceedingsId", "dblp", DblpEndpoint.DBLP_REC_PREFIX, emptyIfNone=True)
k10PlusLink = self.createExternalLink(
row,
"ppnId",
"k10plus",
"https://opac.k10plus.de/DB=2.299/PPNSET?PPN=",
emptyIfNone=True
)
lod.append(
{
Expand All @@ -92,16 +93,26 @@ def reload_aggrid(self, olod: list):
}
)
self.lod_grid.load_lod(lod)
for col_def in self.lod_grid.ag_grid.options["columnDefs"]:
if col_def["field"] == "Item": # Identify the "Title" column
col_def["maxWidth"] = 350 # width in pixels
self.lod_grid.sizeColumnsToFit()

async def on_refresh_button_click(self):
"""
handle the refreshing of the proceedings from wikidata
"""
await run.io_bound(self.refresh_wikidata)

def refresh_wikidata(self):
try:
ui.notify("wikidata refresh button clicked")
with self.solution.container:
ui.notify("wikidata refresh button clicked")
wd_records = self.solution.wdSync.update()
self.lod_grid.load_lod(wd_records)
with self.solution.container:
ui.notify(f"read {len(wd_records)} proceeding records from wikidata")
with self.parent:
self.reload_aggrid(wd_records)
pass
except Exception as ex:
self.solution.handle_exception(ex)
Expand Down
2 changes: 1 addition & 1 deletion ceurws/wikidatasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(
self.wdQuery = self.qm.queriesByName["Proceedings"]
self.baseurl = baseurl
self.wd = Wikidata(debug=debug)
self.sqldb = SQLDB(CEURWS.CACHE_FILE)
self.sqldb = SQLDB(CEURWS.CACHE_FILE,check_same_thread=False)
self.procRecords = None
self.dblpEndpoint = DblpEndpoint(endpoint=dblp_endpoint_url)
self.wikidata_endpoint: Endpoint | None = None
Expand Down

0 comments on commit 8cc15bb

Please sign in to comment.