1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: clear leaderboard after user opted out

This commit is contained in:
Ferdinand Mütsch
2022-10-06 14:52:06 +02:00
parent 23759d526a
commit 1632cea949
3 changed files with 24 additions and 9 deletions

View File

@@ -61,6 +61,15 @@ func (r *LeaderboardRepository) GetAggregatedByUserAndInterval(userId string, ke
return items, nil
}
func (r *LeaderboardRepository) DeleteByUser(userId string) error {
if err := r.db.
Where("user_id = ?", userId).
Delete(models.LeaderboardItem{}).Error; err != nil {
return err
}
return nil
}
func (r *LeaderboardRepository) DeleteByUserAndInterval(userId string, key *models.IntervalKey) error {
if err := r.db.
Where("user_id = ?", userId).

View File

@@ -90,6 +90,7 @@ type IUserRepository interface {
type ILeaderboardRepository interface {
InsertBatch([]*models.LeaderboardItem) error
CountAllByUser(string) (int64, error)
DeleteByUser(string) error
DeleteByUserAndInterval(string, *models.IntervalKey) error
GetAllAggregatedByInterval(*models.IntervalKey, *uint8) ([]*models.LeaderboardItem, error)
GetAggregatedByUserAndInterval(string, *models.IntervalKey, *uint8) ([]*models.LeaderboardItem, error)