Skip to content

Commit

Permalink
Export fixes (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchop authored Apr 3, 2024
1 parent 1a0a978 commit d721f6d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/schemas/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Task(YetiModel, database_arango.ArangoYetiConnector):
# only used for cron tasks
frequency: datetime.timedelta | None = None

def run(self, params: "TaskParams"):
def run(self, params: dict):
"""Runs the task"""
raise NotImplementedError("run() must be implemented in subclass")

Expand Down
1 change: 1 addition & 0 deletions core/schemas/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ def render(self, data: list["Observable"], output_file: str | None) -> None | st
os.makedirs(os.path.dirname(output_file), exist_ok=True)
with open(output_file, "w+") as fd:
fd.write(result)
return None
else:
return result
12 changes: 5 additions & 7 deletions core/web/apiv2/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,13 @@ async def patch_export(request: PatchExportRequest) -> ExportTask:
return new


@router.get("/export/{export_name}/content")
async def export_content(export_name: str):
@router.get("/export/{export_id}/content")
async def export_content(export_id: str):
"""Downloads the latest contents of a given ExportTask."""
export = ExportTask.find(name=export_name)
export = ExportTask.get(export_id)
if not export:
raise HTTPException(
status_code=404, detail=f"ExportTask {export_name} not found"
)
return FileResponse(export.output_file)
raise HTTPException(status_code=404, detail=f"ExportTask {export_id} not found")
return FileResponse(export.output_file, headers={"Cache-Control": "no-cache"})


@router.delete("/export/{export_name}")
Expand Down

0 comments on commit d721f6d

Please sign in to comment.