diff --git a/paperless.conf.example b/paperless.conf.example index bb2449e05..3c6566325 100644 --- a/paperless.conf.example +++ b/paperless.conf.example @@ -69,6 +69,7 @@ #PAPERLESS_POST_CONSUME_SCRIPT=/path/to/an/arbitrary/script.sh #PAPERLESS_FILENAME_DATE_ORDER=YMD #PAPERLESS_FILENAME_PARSE_TRANSFORMS=[] +#PAPERLESS_NUMBER_OF_SUGGESTION_DATES=5 #PAPERLESS_THUMBNAIL_FONT_NAME= #PAPERLESS_IGNORE_DATES= #PAPERLESS_ENABLE_UPDATE_CHECK= diff --git a/src/documents/views.py b/src/documents/views.py index f0061cf2b..8500bf372 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -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( { diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 2ce99ac0e..f0c24feea 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -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", "[]")):