mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 22:54:27 -04:00
clearer sql parsing and dumping
This commit is contained in:
parent
cdb70c73df
commit
35aa8c8902
2 changed files with 5 additions and 8 deletions
|
@ -9,16 +9,13 @@ from ..config import setup_django
|
|||
|
||||
### Main Links Index
|
||||
|
||||
sql_keys = ('url', 'timestamp', 'title', 'tags', 'updated')
|
||||
|
||||
|
||||
@enforce_types
|
||||
def parse_sql_main_index() -> Iterator[Link]:
|
||||
setup_django()
|
||||
from core.models import Page
|
||||
|
||||
return (
|
||||
page.as_json(*sql_keys)
|
||||
page.as_json(*Page.keys)
|
||||
for page in Page.objects.all()
|
||||
)
|
||||
|
||||
|
@ -28,5 +25,5 @@ def write_sql_main_index(links: List[Link]) -> None:
|
|||
from core.models import Page
|
||||
|
||||
for link in links:
|
||||
info = {k: v for k, v in link._asdict().items() if k in sql_keys}
|
||||
info = {k: v for k, v in link._asdict().items() if k in Page.keys}
|
||||
Page.objects.update_or_create(url=link.url, defaults=info)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue