mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Sort elements by ILIAS id to ensure deterministic ordering
This commit is contained in:
parent
8ec3f41251
commit
ee67f9f472
@ -38,6 +38,17 @@ class IliasPageElement:
|
|||||||
mtime: Optional[datetime] = None
|
mtime: Optional[datetime] = None
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
|
|
||||||
|
def id(self) -> str:
|
||||||
|
regexes = [r"eid=(?P<id>[0-9a-z\-]+)", r"file_(?P<id>\d+)", r"ref_id=(?P<id>\d+)"]
|
||||||
|
|
||||||
|
for regex in regexes:
|
||||||
|
if match := re.search(regex, self.url):
|
||||||
|
return match.groupdict()["id"]
|
||||||
|
|
||||||
|
# Fall back to URL
|
||||||
|
log.warn(f"Didn't find identity for {self.name} - {self.url}. Please report this.")
|
||||||
|
return self.url
|
||||||
|
|
||||||
|
|
||||||
class IliasPage:
|
class IliasPage:
|
||||||
|
|
||||||
|
@ -230,6 +230,8 @@ instance's greatest bottleneck.
|
|||||||
# Fill up our task list with the found elements
|
# Fill up our task list with the found elements
|
||||||
await gather_elements()
|
await gather_elements()
|
||||||
|
|
||||||
|
elements.sort(key=lambda e: e.id())
|
||||||
|
|
||||||
tasks: List[Awaitable[None]] = []
|
tasks: List[Awaitable[None]] = []
|
||||||
for element in elements:
|
for element in elements:
|
||||||
if handle := await self._handle_ilias_element(PurePath("."), element):
|
if handle := await self._handle_ilias_element(PurePath("."), element):
|
||||||
@ -280,6 +282,8 @@ instance's greatest bottleneck.
|
|||||||
# Fill up our task list with the found elements
|
# Fill up our task list with the found elements
|
||||||
await gather_elements()
|
await gather_elements()
|
||||||
|
|
||||||
|
elements.sort(key=lambda e: e.id())
|
||||||
|
|
||||||
tasks: List[Awaitable[None]] = []
|
tasks: List[Awaitable[None]] = []
|
||||||
for element in elements:
|
for element in elements:
|
||||||
if handle := await self._handle_ilias_element(cl.path, element):
|
if handle := await self._handle_ilias_element(cl.path, element):
|
||||||
|
Loading…
Reference in New Issue
Block a user