feat: load_main_index returns a queryset now

This commit is contained in:
Cristian 2020-08-20 09:18:25 -05:00 committed by Cristian Vargas
parent a77d6dc235
commit b8585dd92e
2 changed files with 14 additions and 27 deletions

View file

@ -17,6 +17,7 @@ from ..util import (
ExtendedEncoder,
)
from ..config import (
setup_django,
ARCHIVE_DIR_NAME,
SQL_INDEX_FILENAME,
JSON_INDEX_FILENAME,
@ -263,17 +264,14 @@ def write_main_index(links: List[Link], out_dir: str=OUTPUT_DIR, finished: bool=
@enforce_types
def load_main_index(out_dir: str=OUTPUT_DIR, warn: bool=True) -> List[Link]:
"""parse and load existing index with any new links from import_path merged in"""
all_links: List[Link] = []
setup_django(out_dir, check_db=True)
from core.models import Snapshot
try:
all_links = list(parse_sql_main_index(out_dir))
list(parse_sql_main_index(out_dir))
return Snapshot.objects.all()
except (KeyboardInterrupt, SystemExit):
raise SystemExit(0)
return all_links
@enforce_types
def load_main_index_meta(out_dir: str=OUTPUT_DIR) -> Optional[dict]:
index_path = os.path.join(out_dir, JSON_INDEX_FILENAME)