fix(translate,automation): fix schedule import/param errors, add translation schedules to Automation view
- Fix ModuleNotFoundError: 4 lazy imports in _schedule_routes.py changed from 3-dot to 4-dot relative imports (src.api.dependencies -> src.dependencies) - Fix TypeError: update_schedule() param name mismatch (timezone -> timezone_str) - Add add_translation_job/remove_translation_job to SchedulerService to register translation schedules with APScheduler via execute_scheduled_translation - Add GET /settings/automation/translation-schedules endpoint returning all translation schedules with joined job names - Update Automation settings page to display translation schedules (cron, timezone, active badge, last run) below validation policies
This commit is contained in:
@@ -25,7 +25,9 @@ from ...schemas.settings import (
|
||||
ValidationPolicyCreate,
|
||||
ValidationPolicyUpdate,
|
||||
ValidationPolicyResponse,
|
||||
TranslationScheduleItem,
|
||||
)
|
||||
from ...models.translate import TranslationSchedule, TranslationJob
|
||||
from ...core.database import get_db
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@@ -598,4 +600,40 @@ async def delete_validation_policy(
|
||||
|
||||
# #endregion delete_validation_policy
|
||||
|
||||
|
||||
# #region get_translation_schedules [C:2] [TYPE Function]
|
||||
# @BRIEF Lists all translation schedules joined with translation job names.
|
||||
@router.get("/automation/translation-schedules", response_model=List[TranslationScheduleItem])
|
||||
async def get_translation_schedules(
|
||||
db: Session = Depends(get_db),
|
||||
_=Depends(has_permission("admin:settings", "READ")),
|
||||
):
|
||||
with belief_scope("get_translation_schedules"):
|
||||
results = (
|
||||
db.query(
|
||||
TranslationSchedule,
|
||||
TranslationJob.name.label("job_name"),
|
||||
)
|
||||
.outerjoin(TranslationJob, TranslationSchedule.job_id == TranslationJob.id)
|
||||
.all()
|
||||
)
|
||||
return [
|
||||
TranslationScheduleItem(
|
||||
schedule_id=ts.id,
|
||||
job_id=ts.job_id,
|
||||
job_name=job_name,
|
||||
cron_expression=ts.cron_expression,
|
||||
timezone=ts.timezone,
|
||||
is_active=ts.is_active,
|
||||
last_run_at=ts.last_run_at,
|
||||
next_run_at=ts.next_run_at,
|
||||
created_by=ts.created_by,
|
||||
created_at=ts.created_at,
|
||||
)
|
||||
for ts, job_name in results
|
||||
]
|
||||
|
||||
|
||||
# #endregion get_translation_schedules
|
||||
|
||||
# #endregion SettingsRouter
|
||||
|
||||
Reference in New Issue
Block a user