Skip to content

Commit

Permalink
Merge pull request #12 from intelops/feat/last_scan_time
Browse files Browse the repository at this point in the history
added last_scan_time
  • Loading branch information
jegathintelops authored Apr 1, 2024
2 parents 32c13cf + 4bff685 commit 664d402
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/proact_server/routes/schedule/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ async def list_schedules(db: Session) -> list[ScheduleResponse]:
updated_schedules = []
for schedule in schedules:
schedule_status = db.query(ScanConfigs.schedule_status).filter(ScanConfigs.schedule_id == schedule.schedule_id).first()
last_scan_time = db.query(ScanStatus.datetime).filter(ScanStatus.execution_id == db.query(Executions.execution_id).filter(Executions.schedule_id == schedule.schedule_id).first().execution_id).order_by(ScanStatus.datetime.desc()).first()
if(schedule_status):
schedule_status = schedule_status[0]
schedule = schedule._asdict()
schedule["schedule_status"] = schedule_status
if(last_scan_time):
schedule["last_scan_time"] = last_scan_time[0]
updated_schedules.append(schedule)
#Convert to list of ScheduleResponse using ** expression
schedules = [ScheduleResponse(**schedule) for schedule in updated_schedules]
Expand Down
2 changes: 2 additions & 0 deletions src/proact_server/utils/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ def convert_to_string(cls, v):
schedule_id: str
schedule_name: str
schedule_status: str
# optional last_scan_time
last_scan_time: Optional[str] = Field(default="")


class ExecutionResponse(BaseModel):
Expand Down

0 comments on commit 664d402

Please sign in to comment.