-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore:add cache management script and improve rebuild process
Introduce `manage_cache.py` for handling cache rebuilds, including a new script entry in `pyproject.toml`. Refactor imports and add logging to enhance clarity and maintainability in the codebase. Also, import `django-environ` and update the Makefile for additional cache rebuild command.
- Loading branch information
1 parent
423ef50
commit f2ce5a0
Showing
9 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# flake8: noqa | ||
import os | ||
import time | ||
|
||
import django | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") | ||
|
||
django.setup() | ||
|
||
from fbr.cache.legislation import Legislation | ||
from fbr.cache.public_gateway import PublicGateway | ||
from fbr.search.config import SearchDocumentConfig | ||
from fbr.search.utils.documents import clear_all_documents | ||
|
||
|
||
def rebuild_cache(): | ||
try: | ||
start = time.time() | ||
clear_all_documents() | ||
config = SearchDocumentConfig(search_query="", timeout=20) | ||
Legislation().build_cache(config) | ||
PublicGateway().build_cache(config) | ||
end = time.time() | ||
return {"message": "rebuilt cache", "duration": round(end - start, 2)} | ||
except Exception as e: | ||
return {"message": f"error clearing documents: {e}"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from setuptools import find_packages, setup | ||
|
||
setup( | ||
name="fbr", | ||
version="0.1", | ||
packages=find_packages(), | ||
install_requires=[ | ||
# Add your package dependencies here | ||
"requests", | ||
"pandas", | ||
"django", | ||
"dj_database_url", | ||
], | ||
entry_points={ | ||
"console_scripts": [ | ||
# Define command-line scripts here if needed | ||
# e.g., 'my-command = fbr.module:function', | ||
], | ||
}, | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters