Skip to content

Commit

Permalink
bugfix: fixed get all friends
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashLight committed Dec 20, 2024
1 parent 7849c56 commit d176163
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/profile/repository/QueryConsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const (

GetProfileByID = "SELECT profile.id, first_name, last_name, bio, avatar FROM profile WHERE profile.id = $1 LIMIT 1;"
GetStatus = "SELECT status FROM friend WHERE (sender = $1 AND receiver = $2) LIMIT 1"
GetAllProfilesBatch = "WITH friends AS (SELECT sender AS friend FROM friend WHERE (receiver = $1 AND status = 0) UNION SELECT receiver AS friend FROM friend WHERE (sender = $1 AND status = 0)), subscriptions AS (SELECT sender AS subscription FROM friend WHERE (receiver = $1 AND status = -1) UNION SELECT receiver AS subscriber FROM friend WHERE (sender = $1 AND status = 1)) SELECT p.id, first_name, last_name, avatar FROM profile p WHERE p.id <> $1 AND p.id > $2 AND p.id NOT IN (SELECT friend FROM friends) AND p.id NOT IN (SELECT subscription FROM subscriptions) ORDER BY p.id LIMIT $3;"
GetAllProfilesBatch = "WITH friends AS (SELECT sender AS friend FROM friend WHERE (receiver = $1 AND status = 0) UNION SELECT receiver AS friend FROM friend WHERE (sender = $1 AND status = 0)), subscriptions AS (SELECT sender AS subscription FROM friend WHERE (receiver = $1 AND status = -1) UNION SELECT receiver AS subscription FROM friend WHERE (sender = $1 AND status = 1)), subscribers AS (SELECT sender AS subscriber FROM friend WHERE (receiver = $1 AND status = 1) UNION SELECT receiver AS subscriber FROM friend WHERE (sender = $1 AND status = -1)) SELECT p.id, first_name, last_name, avatar FROM profile p WHERE p.id <> $1 AND p.id > $2 AND p.id NOT IN (SELECT friend FROM friends) AND p.id NOT IN (SELECT subscription FROM subscriptions) AND p.id NOT IN (SELECT subscriber FROM subscribers) ORDER BY p.id LIMIT $3;"
UpdateProfile = "UPDATE profile SET first_name = $1, last_name = $2, bio = $3 WHERE id = $4;"
UpdateProfileAvatar = "UPDATE profile SET avatar = $2, first_name = $3, last_name = $4, bio = $5 WHERE id = $1;"
DeleteProfile = "DELETE FROM profile WHERE id = $1;"
Expand Down

0 comments on commit d176163

Please sign in to comment.