Пример #1
0
def workitems_list(
        since: Optional[datetime.datetime] = None,
        until: Optional[datetime.datetime] = None,
        status: Optional[list[int]] = Query([1]),
        facility: Optional[str] = None,
        user: UKRDCUser = Security(auth.get_user()),
        jtrace: Session = Depends(get_jtrace),
        sorter: SQLASorter = Depends(
            make_sqla_sorter(
                [WorkItem.id, WorkItem.last_updated],
                default_sort_by=WorkItem.last_updated,
            )),
        audit: Auditer = Depends(get_auditer),
):
    """Retreive a list of open work items from the EMPI"""
    query = get_workitems(jtrace,
                          user,
                          statuses=status,
                          facility=facility,
                          since=since,
                          until=until)
    page = paginate(sorter.sort(query))

    for item in page.items:  # type: ignore
        audit.add_workitem(item)

    return page
Пример #2
0
def workitem_detail(
        workitem_id: int,
        user: UKRDCUser = Security(auth.get_user()),
        jtrace: Session = Depends(get_jtrace),
        audit: Auditer = Depends(get_auditer),
):
    """Retreive a particular work item from the EMPI"""
    workitem = get_extended_workitem(jtrace, workitem_id, user)
    audit.add_workitem(workitem)
    return workitem
Пример #3
0
def workitem_collection(
        workitem_id: int,
        user: UKRDCUser = Security(auth.get_user()),
        jtrace: Session = Depends(get_jtrace),
        audit: Auditer = Depends(get_auditer),
):
    """Retreive a list of other work items related to a particular work item"""
    collection = get_workitem_collection(jtrace, workitem_id, user).all()

    for workitem in collection:
        audit.add_workitem(workitem)

    return collection
Пример #4
0
async def error_workitems(
        message_id: str,
        user: UKRDCUser = Security(auth.get_user()),
        errorsdb: Session = Depends(get_errorsdb),
        jtrace: Session = Depends(get_jtrace),
        audit: Auditer = Depends(get_auditer),
):
    """Retreive WorkItems associated with a specific error message"""
    message = get_message(errorsdb, message_id, user)

    workitems = get_workitems_related_to_message(jtrace, errorsdb,
                                                 str(message.id), user).all()

    message_audit = audit.add_event(Resource.MESSAGE, message.id,
                                    MessageOperation.READ)
    for item in workitems:
        audit.add_workitem(item, parent=message_audit)

    return workitems
Пример #5
0
def master_record_workitems(
    record_id: int,
    user: UKRDCUser = Security(auth.get_user()),
    jtrace: Session = Depends(get_jtrace),
    audit: Auditer = Depends(get_auditer),
):
    """Retreive a list of work items related to a particular master record."""
    related: list[MasterRecord] = get_masterrecords_related_to_masterrecord(
        jtrace, record_id, user
    ).all()

    workitems = get_workitems(
        jtrace, user, master_id=[record.id for record in related]
    ).all()

    record_audit = audit.add_event(
        Resource.MASTER_RECORD, record_id, AuditOperation.READ
    )
    for item in workitems:
        audit.add_workitem(item, parent=record_audit)

    return workitems