Skip to content

Commit

Permalink
Include DeletionRequestID in WorkItemsView
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondap committed Jan 29, 2024
1 parent 041a7c6 commit 968e877
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
49 changes: 48 additions & 1 deletion db/migrations/011_batch_deletion_work_items.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,54 @@ begin

-- Now remove the work_item_id column from deletion requests
alter table deletion_requests drop column work_item_id;



drop view if exists work_items_view;

CREATE OR REPLACE VIEW public.work_items_view
AS SELECT wi.id,
wi.institution_id,
i.name AS institution_name,
i.identifier AS institution_identifier,
wi.intellectual_object_id,
io.identifier AS object_identifier,
io.alt_identifier,
io.bag_group_identifier,
io.storage_option,
io.bagit_profile_identifier,
io.source_organization,
io.internal_sender_identifier,
wi.generic_file_id,
gf.identifier AS generic_file_identifier,
wi.name,
wi.etag,
wi.bucket,
wi."user",
wi.note,
wi.action,
wi.stage,
wi.status,
wi.outcome,
wi.bag_date,
wi.date_processed,
wi.retry,
wi.node,
wi.pid,
wi.needs_admin_review,
wi.size,
wi.queued_at,
wi.stage_started_at,
wi.aptrust_approver,
wi.inst_approver,
wi.deletion_request_id,
wi.created_at,
wi.updated_at
FROM work_items wi
LEFT JOIN institutions i ON wi.institution_id = i.id
LEFT JOIN intellectual_objects io ON wi.intellectual_object_id = io.id
LEFT JOIN generic_files gf ON wi.generic_file_id = gf.id;


end if;
end
$$;
Expand Down
7 changes: 6 additions & 1 deletion member_api_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ openapi: 3.0.0
info:
title: APTrust Registry Member API
description: Open API documentation for version 3 of the APTrust Member API.
version: '3.0'
version: '3.0.1'
contact:
email: "[email protected]"
license:
Expand Down Expand Up @@ -800,6 +800,11 @@ components:
type: string
format: date-time
description: The date and time of last known activity on this work item. This timestamp may change several times during multipart processes such as ingest.
deletion_request_id:
type: integer
format: int64
description: The ID of the file or object deletion request related to this item. This will be null for all actions other than Delete.
nullable: false
etag:
type: string
description: The etag of tar file uploaded for ingest.
Expand Down
1 change: 1 addition & 0 deletions pgmodels/work_item_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type WorkItemView struct {
StageStartedAt time.Time `json:"stage_started_at" pg:"stage_started_at"`
APTrustApprover string `json:"aptrust_approver" pg:"aptrust_approver"`
InstApprover string `json:"inst_approver" pg:"inst_approver"`
DeletionRequestID int64 `json:"deletion_request_id" pg:"deletion_request_id"`
CreatedAt time.Time `json:"created_at" pg:"created_at"`
UpdatedAt time.Time `json:"updated_at" pg:"updated_at"`
}
Expand Down
2 changes: 1 addition & 1 deletion views/deletions/approved_object.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<p>All files belonging to thes objects will be deleted from preservation storage shortly. We'll retain a tombstone record of the object and its files along with PREMIS events recording when each item was deleted and at whose request.</p>

<p><a href="/work_items/show/{{ .deletionRequest.WorkItemID }}">Work Item #{{ .deletionRequest.WorkItemID }}</a> shows the status of this deletion.</p>
<p>Check the <a href="/work_items">Work Items list</a> to see the status of this deletion.</p>

<a class="button mr-3" href="/deletions">Back to Deletions List</a>
</div>
Expand Down
8 changes: 8 additions & 0 deletions web/webui/deletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,18 @@ func (del *Deletion) initObjectDeletionRequest(institutionID int64, objIDs []int
// CreateWorkItem creates a WorkItem describing this deletion. We call
// this only if the admin approves the deletion.
func (del *Deletion) CreateObjDeletionWorkItem(obj *pgmodels.IntellectualObject) error {
if del.DeletionRequest == nil || del.DeletionRequest.ID == 0 {
errMsg := "Cannot create deletion work item because deletion request id is zero."
common.Context().Log.Error().Msgf(errMsg)
return fmt.Errorf(errMsg)
}
common.Context().Log.Warn().Msgf("Creating deletion work item for object %d - %s", obj.ID, obj.Identifier)
workItem, err := pgmodels.NewDeletionItem(obj, nil, del.DeletionRequest.RequestedBy, del.DeletionRequest.ConfirmedBy, del.DeletionRequest.ID)
if err != nil {
common.Context().Log.Error().Msgf(err.Error())
return err
}
common.Context().Log.Warn().Msgf("Created deletion work item %d with deletion request id %d", workItem.ID, workItem.DeletionRequestID)
del.DeletionRequest.WorkItems = append(del.DeletionRequest.WorkItems, workItem)
return nil
}
Expand Down

0 comments on commit 968e877

Please sign in to comment.