Skip to content

Commit

Permalink
feat: floor_punishment distinct content
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Oct 20, 2023
1 parent e91b735 commit 46bcb95
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apis/floor/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,16 @@ func GetPunishmentHistory(c *fiber.Ctx) error {
// search DB for user punishment history
punishments := make([]string, 0, 10)
err = DB.Raw(
`SELECT floor.content
FROM floor JOIN floor_history ON floor.id = floor_history.floor_id
WHERE floor.user_id <> floor_history.user_id
AND floor.user_id = ?
AND floor.deleted`, userID).Scan(&punishments).Error
`SELECT f.content
FROM floor f
WHERE f.id IN (
SELECT distinct floor.id
FROM floor
JOIN floor_history ON floor.id = floor_history.floor_id
WHERE floor.user_id <> floor_history.user_id
AND floor.user_id = ?
AND floor.deleted = true
)`, userID).Scan(&punishments).Error
if err != nil {
return err
}
Expand Down

0 comments on commit 46bcb95

Please sign in to comment.