diff --git a/archivebox/core/models.py b/archivebox/core/models.py index 1951c37d..6fdcdae2 100644 --- a/archivebox/core/models.py +++ b/archivebox/core/models.py @@ -18,15 +18,15 @@ class Page(models.Model): updated = models.DateTimeField(null=True, default=None) # bookmarked = models.DateTimeField() - sql_args = ('url', 'timestamp', 'title', 'tags', 'updated') + keys = ('url', 'timestamp', 'title', 'tags', 'updated') @classmethod def from_json(cls, info: dict): - info = {k: v for k, v in info.items() if k in cls.sql_args} + info = {k: v for k, v in info.items() if k in cls.keys} return cls(**info) def as_json(self, *args) -> dict: - args = args or self.sql_args + args = args or self.keys return { key: getattr(self, key) for key in args diff --git a/archivebox/legacy/storage/sql.py b/archivebox/legacy/storage/sql.py index c4f03bb0..90a0c412 100644 --- a/archivebox/legacy/storage/sql.py +++ b/archivebox/legacy/storage/sql.py @@ -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)