36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from inbox.enums import Candidate_application_Status
|
|
|
|
|
|
def serialize_pipeline_counts(inbox_counts,manual_counts) -> dict:
|
|
by_status={stage.value:0 for stage in Candidate_application_Status}
|
|
by_status["UNKNOWN"]=0
|
|
inbox_n=0
|
|
manual_n=0
|
|
for key,n in (inbox_counts or {}).items():
|
|
n=int(n or 0)
|
|
inbox_n+=n
|
|
bucket=key if key in by_status else "UNKNOWN"
|
|
by_status[bucket]+=n
|
|
for key,n in (manual_counts or {}).items():
|
|
n=int(n or 0)
|
|
manual_n+=n
|
|
bucket=key if key in by_status else "UNKNOWN"
|
|
by_status[bucket]+=n
|
|
return {"by_status":by_status,"inbox":inbox_n,"manual_upload":manual_n}
|
|
|
|
|
|
def serialize_stage_transition(row) -> dict:
|
|
return {
|
|
"id": str(row.id),
|
|
"inbox_id": row.inbox_id,
|
|
"manual_upload_candidate_id": str(row.manual_upload_candidate_id) if row.manual_upload_candidate_id else None,
|
|
"from_stage": row.from_stage,
|
|
"to_stage": row.to_stage,
|
|
"valid_from": row.valid_from.isoformat() if row.valid_from else None,
|
|
"valid_to": row.valid_to.isoformat() if row.valid_to else None,
|
|
"changed_by": str(row.changed_by) if row.changed_by else None,
|
|
"actor_kind": row.actor_kind,
|
|
"change_reason": row.change_reason,
|
|
"created_at": row.created_at.isoformat() if row.created_at else None,
|
|
}
|