mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-21 10:25:11 -04:00
deduplicate method history when merging links
This commit is contained in:
parent
0d2f7eb58e
commit
0272c9b8c0
1 changed files with 11 additions and 0 deletions
|
@ -28,6 +28,7 @@ from .util import (
|
|||
TimedProgress,
|
||||
copy_and_overwrite,
|
||||
atomic_write,
|
||||
ExtendedEncoder,
|
||||
)
|
||||
from .parse import parse_links
|
||||
from .logs import (
|
||||
|
@ -93,6 +94,16 @@ def merge_links(a: Link, b: Link) -> Link:
|
|||
method: (a.history.get(method) or []) + (b.history.get(method) or [])
|
||||
for method in all_methods
|
||||
}
|
||||
for method in all_methods:
|
||||
deduped_jsons = {
|
||||
json.dumps(result, sort_keys=True, cls=ExtendedEncoder)
|
||||
for result in history[method]
|
||||
}
|
||||
history[method] = list(reversed(sorted(
|
||||
(ArchiveResult.from_json(json.loads(result)) for result in deduped_jsons),
|
||||
key=lambda result: result.start_ts,
|
||||
)))
|
||||
|
||||
|
||||
return Link(
|
||||
url=url,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue