Last active
June 1, 2022 14:25
-
-
Save kmiscia/0794f7f7fddf3294e6fc998597578a55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Seller Timelines | |
SELECT | |
timelines.name, | |
versions.created_at as fell_through_at | |
FROM | |
timelines | |
LEFT OUTER JOIN timeline_fields on timeline_fields.timeline_id = timelines.id | |
LEFT OUTER JOIN versions ON versions.item_id = timeline_fields.id AND versions.item_type = 'TimelineField' | |
WHERE | |
timelines.is_template = FALSE | |
AND | |
timelines.rewind_id IS NULL | |
AND | |
timelines.type = 'Timelines::SellerTimeline' | |
AND | |
timeline_fields.slug = 'status' | |
AND | |
versions.event = 'update' | |
AND | |
versions.object_changes ->> 'value' = '["Pending", "Active"]' | |
ORDER BY | |
versions.created_at DESC; | |
-- Buyer Timelines | |
SELECT | |
timelines.name, | |
versions.created_at as fell_through_at | |
FROM | |
timelines | |
LEFT OUTER JOIN timeline_fields on timeline_fields.timeline_id = timelines.id | |
LEFT OUTER JOIN versions ON versions.item_id = timeline_fields.id AND versions.item_type = 'TimelineField' | |
WHERE | |
timelines.is_template = FALSE | |
AND | |
timelines.rewind_id IS NULL | |
AND | |
timelines.type = 'Timelines::BuyerTimeline' | |
AND | |
timeline_fields.slug = 'status' | |
AND | |
versions.event = 'update' | |
AND | |
versions.object_changes ->> 'value' = '["Pending", "Active Search"]' | |
ORDER BY | |
versions.created_at DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment