diff --git a/autocomplete_multi_models/management/commands/makeautocompleteindex.py b/autocomplete_multi_models/management/commands/makeautocompleteindex.py index fd389266acbe05527259684b75491ca032c46e24..b10880a9f8b4ac7abf49e15e13dd8c4287a3238e 100644 --- a/autocomplete_multi_models/management/commands/makeautocompleteindex.py +++ b/autocomplete_multi_models/management/commands/makeautocompleteindex.py @@ -18,4 +18,21 @@ class Command(BaseCommand): business_process.rebuild_index() te = time.time() print(f"Index rebuild in {int((te - ts) * 100) / 100}s, it contains {models.IndexedWord.objects.count()} words") + if not models.IndexedWord.objects.exists(): + print("DB is empty, prefilling it with some words") + for s in [ + "Coming soon", + "coming soon", + "coming", + "soon", + "Work in progress", + "work", + "progress", + "HUB", + "Bioinformatics and Biostatistics", + "Bioinformatics and Biostatistics HUB", + "bioinformatics", + "biostatistics", + ]: + models.IndexedWord.objects.get_or_create(word=s, occurrence=1) business_process.set_setting_in_storage(utils.REBUILD_NEEDED, False) diff --git a/setup.cfg b/setup.cfg index 8090a51edfdd01d0fa7859d135ef9eaaec2acd64..2849107027d4f271adb2db5f040dd656b6ae7747 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = autocomplete-multi-models -version = 0.4.1 +version = 0.4.3 description = An app that index fields across multiple models, and expose an api to query for word similar to the query. long_description = file: README.md author = Bryan Brancotte