feat(settings): add setting to set number of suggested dates

This commit is contained in:
Matthias Eck
2022-08-06 13:02:08 +02:00
parent f6e4339069
commit f1084cbdcf
3 changed files with 9 additions and 1 deletions

View File

@@ -337,7 +337,9 @@ class DocumentViewSet(
classifier = load_classifier()
gen = parse_date_generator(doc.filename, doc.content)
dates = {i for i in itertools.islice(gen, 5)}
dates = sorted(
{i for i in itertools.islice(gen, settings.NUMBER_OF_SUGGESTED_DATES)},
)
return Response(
{

View File

@@ -588,6 +588,11 @@ POST_CONSUME_SCRIPT = os.getenv("PAPERLESS_POST_CONSUME_SCRIPT")
DATE_ORDER = os.getenv("PAPERLESS_DATE_ORDER", "DMY")
FILENAME_DATE_ORDER = os.getenv("PAPERLESS_FILENAME_DATE_ORDER")
# Number of dates used as suggestions in the frontend
# The number counter from top to bottom.
# Duplicates will be removed, which will result in less shown suggestion dates.
NUMBER_OF_SUGGESTED_DATES = __get_int("PAPERLESS_NUMBER_OF_SUGGESTED_DATES", 0)
# Transformations applied before filename parsing
FILENAME_PARSE_TRANSFORMS = []
for t in json.loads(os.getenv("PAPERLESS_FILENAME_PARSE_TRANSFORMS", "[]")):