Skip to content

Commit

Permalink
MODAUD-180 updates sql
Browse files Browse the repository at this point in the history
  • Loading branch information
mrussakova committed Jan 25, 2024
1 parent b740dfb commit ff88936
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ 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,
COALESCE(LAG(modified_content_snapshot ->> 'receivingStatus') OVER w, '') AS previous_status,
COALESCE(LAG(modified_content_snapshot ->> 'claimingInterval') OVER w, '') AS previous_claiming_interval
LAG(modified_content_snapshot ->> 'receivingStatus') OVER w AS previous_status,
LAG(modified_content_snapshot ->> 'claimingInterval') OVER w AS previous_claiming_interval
FROM %s
WHERE piece_id=$1
WINDOW w AS (PARTITION BY piece_id ORDER BY action_date)
)
SELECT id, action, piece_id, user_id, event_date, action_date, modified_content_snapshot
FROM StatusChanges
WHERE modified_content_snapshot ->> 'receivingStatus' <> previous_status
OR modified_content_snapshot ->> 'claimingInterval' <> previous_claiming_interval
WHERE modified_content_snapshot ->> 'receivingStatus' IS DISTINCT FROM previous_status
OR modified_content_snapshot ->> 'claimingInterval' IS DISTINCT FROM previous_claiming_interval
%s LIMIT $2 OFFSET $3
""";

Expand Down

0 comments on commit ff88936

Please sign in to comment.