Skip to content

Commit

Permalink
[MODAUD-174] - minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Nov 14, 2023
1 parent 821a46a commit d43d0ee
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public class PieceEventsDaoImpl implements PieceEventsDao {
private static final String GET_STATUS_CHANGE_HISTORY_BY_PIECE_ID_SQL =
"""
WITH StatusChanges AS (SELECT id, action, piece_id, user_id, event_date, action_date, modified_content_snapshot,
LAG(modified_content_snapshot ->> 'status') OVER (PARTITION BY piece_id ORDER BY action_date) AS previous_status FROM %s
LAG(modified_content_snapshot ->> 'receivingStatus') 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 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, '')
WHERE piece_id = $1 and modified_content_snapshot ->> 'receivingStatus' <> COALESCE(previous_status, ''))
FROM StatusChanges WHERE piece_id = $1 and modified_content_snapshot ->> 'receivingStatus' <> COALESCE(previous_status, '')
%s LIMIT $2 OFFSET $3
""";

Expand Down

0 comments on commit d43d0ee

Please sign in to comment.