Add configuration rules, refactor settings management, and enhance import functionality
- Introduced a new configuration file `.cursorrules` to define coding standards, error handling, testing requirements, and project-specific guidelines. - Refactored `config.py` to implement a `Settings` dataclass for better management of environment variables, improving testability and maintainability. - Updated the import duty schedule handler to utilize session management with `session_scope`, ensuring proper database session handling. - Enhanced the import service to streamline the duty schedule import process, improving code organization and readability. - Added new service layer functions to encapsulate business logic related to group duty pinning and duty schedule imports. - Updated README documentation to reflect the new configuration structure and improved import functionality.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
"""SQLAlchemy engine and session factory.
|
||||
|
||||
Note: Engine and session factory are cached globally per process. Only one
|
||||
DATABASE_URL is effectively used for the process lifetime. Using a different
|
||||
URL later (e.g. in tests with in-memory SQLite) would still use the first
|
||||
engine. To support multiple URLs, cache by database_url (e.g. a dict keyed by URL).
|
||||
Engine and session factory are cached globally per process. Only one DATABASE_URL
|
||||
is effectively used for the process lifetime. Using a different URL later (e.g. in
|
||||
tests with in-memory SQLite) would still use the first engine. To use a different
|
||||
URL in tests, set env (e.g. DATABASE_URL) before the first import of this module, or
|
||||
clear _engine and _SessionLocal in test fixtures. Prefer session_scope() for all
|
||||
callers so sessions are always closed and rolled back on error.
|
||||
"""
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
Reference in New Issue
Block a user