Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion audit/src/org/labkey/audit/AuditController.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public Object execute(AuditTransactionForm form, BindException errors)
// GitHub Issue 1307: use product folder data CF
ContainerFilter cf = getContainer().getProductFoldersDataContainerFilter(elevatedUser);
if (form.isSampleType())
results = AuditLogImpl.get().getTransactionSampleIds(form.getTransactionAuditId(), elevatedUser, getContainer(), cf);
results = AuditLogImpl.get().getTransactionSampleIds(form.getTransactionAuditId(), form.isInsertOnly(), elevatedUser, getContainer(), cf);
else
results = AuditLogImpl.get().getTransactionSourceIds(form.getTransactionAuditId(), elevatedUser, getContainer(), cf);

Expand All @@ -404,6 +404,7 @@ public static class AuditTransactionForm
private Long _transactionAuditId;
private String _dataType;
private boolean _isSampleType;
private Boolean _insertOnly;

public Long getTransactionAuditId()
{
Expand All @@ -425,6 +426,16 @@ public void setDataType(String dataType)
_dataType = dataType;
}

public Boolean isInsertOnly()
{
return Boolean.TRUE.equals(_insertOnly);
}

public void setInsertOnly(Boolean insertOnly)
{
_insertOnly = insertOnly;
}

public boolean isSampleType()
{
return _isSampleType;
Expand Down
14 changes: 9 additions & 5 deletions audit/src/org/labkey/audit/AuditLogImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public ActionURL getAuditUrl()

public record TransactionRowIds(Set<Long> rowIds, Map<Long, Long> dataTypeRowCounts) {}

public TransactionRowIds getTransactionSampleIds(long transactionAuditId, User user, Container container, @Nullable ContainerFilter containerFilter)
public TransactionRowIds getTransactionSampleIds(long transactionAuditId, boolean includeInsertEventOnly, User user, Container container, @Nullable ContainerFilter containerFilter)
{
List<AuditTypeEvent> transactionEvents = TRANSACTION_EVENT_CACHE.get(transactionAuditId).second;
List<SampleTimelineAuditEvent> events;
Expand All @@ -268,10 +268,14 @@ public TransactionRowIds getTransactionSampleIds(long transactionAuditId, User u
.map(SampleTimelineAuditEvent.class::cast)
.toList();
}
// Drop the secondary "added/removed sample to/from job" events; the same sample has a primary registration/update event in the transaction, so counting these would double-count it.
events = events.stream()
.filter(event -> SampleTimelineAuditEvent.SampleTimelineEventType.INSERT.getComment().equals(event.getComment()) || SampleTimelineAuditEvent.SampleTimelineEventType.MERGE.getComment().equals(event.getComment()))
.toList();

if (includeInsertEventOnly)
{
// Drop the secondary "added/removed sample to/from job/update parent status" events; the same sample has a primary registration/update event in the transaction, so counting these would double-count it.
events = events.stream()
.filter(event -> SampleTimelineAuditEvent.SampleTimelineEventType.INSERT.getComment().equals(event.getComment()) || SampleTimelineAuditEvent.SampleTimelineEventType.MERGE.getComment().equals(event.getComment()))
.toList();
}

Map<Long, Long> dataTypeRowCounts = new HashMap<>();
// Return distinct set of sampleIds, since there might be multiple events in transaction for the same sample
Expand Down