Guest User

Untitled

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