Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- | id | uuid | leader_id | notifable_id | data | created_at
- -----------------------------------------------------------------------------------
- | 1 | 001w2cwfoqzp8F3... | 1 | 0 | Post A | 2018-04-19 00:00:00
- | 2 | lvbuX4d5qCHJUIN... | 1 | 0 | Post B | 2018-04-20 00:00:00
- | 3 | eEq5r5g5jApkKgd... | 0 | 14 | Follow | 2018-04-21 00:00:00
- | id | leader_id | follower_id | created_at
- ----------------------------------------------------
- | 1 | 1 | 14 | 2018-04-18 00:00:00 // followed before, has notifs
- | 2 | 1 | 15 | 2018-04-22 00:00:00 // followed after, no notifs
- | notification_uuid | follower_id | read_at
- --------------------------------------------------------
- qIXE97AP49muZf... | 17 | 2018-04-21 00:00:00 // not for 14, we ignore it
- SELECT nf.id, nf.uuid, nf.leader_id, nf.data, nf.created_at, nfr.read_at
- FROM notification_followers nf
- LEFT JOIN user_follows uf ON uf.leader_id = nf.leader_id AND uf.follower_id = 14
- LEFT JOIN notification_followers_read nfr ON nf.uuid = nfr.notification_uuid AND nfr.follower_id = 14
- WHERE (nf.created_at > uf.created_at OR notifiable_id = 14)
- ORDER BY nf.id DESC LIMIT 10
Add Comment
Please, Sign In to add comment