Skip to content

Commit

Permalink
[MODAUD-174] - Implemented status change history feature and cleaned …
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
azizbekxm committed Nov 14, 2023
1 parent 3811d8a commit 1646698
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ WITH StatusChanges AS (SELECT id, action, piece_id, user_id, event_date, action_
LAG(modified_content_snapshot ->> 'status') OVER (PARTITION BY piece_id ORDER BY action_date) AS previous_status FROM %s
)
SELECT id, action, piece_id, user_id, event_date, action_date, modified_content_snapshot,
(SELECT count(*) AS total_records FROM %s WHERE piece_id = $1) FROM StatusChanges
WHERE piece_id = $1 and modified_content_snapshot ->> 'status' <> COALESCE(previous_status, '')
(SELECT COUNT(*) AS total_records FROM StatusChanges
WHERE piece_id = $1 and modified_content_snapshot ->> 'status' <> COALESCE(previous_status, ''))
FROM StatusChanges WHERE piece_id = $1 and modified_content_snapshot ->> 'status' <> COALESCE(previous_status, '')
%s LIMIT $2 OFFSET $3
""";

Expand Down Expand Up @@ -98,7 +99,7 @@ public Future<PieceAuditEventCollection> getAuditEventsWithUniqueStatusByPieceId
try {
LOGGER.info("getAuditEventsByOrderId:: Trying to Retrieve AuditEvent with piece id : {}", pieceId);
String logTable = formatDBTableName(tenantId, TABLE_NAME);
String query = format(GET_STATUS_CHANGE_HISTORY_BY_PIECE_ID_SQL, logTable, logTable, format(ORDER_BY_PATTERN, sortBy, sortOrder));
String query = format(GET_STATUS_CHANGE_HISTORY_BY_PIECE_ID_SQL, logTable, format(ORDER_BY_PATTERN, sortBy, sortOrder));
Tuple queryParams = Tuple.of(UUID.fromString(pieceId), limit, offset);
pgClientFactory.createInstance(tenantId).selectRead(query, queryParams, promise);
} catch (Exception e) {
Expand Down

0 comments on commit 1646698

Please sign in to comment.