generated from PenaSide/GolangTemplate
duplicate processing
This commit is contained in:
parent
ae5e06be33
commit
1231ee9aaa
@ -116,6 +116,7 @@ func (receiver *HistoryRepository) GetRecentTariffs(ctx context.Context, userID
|
||||
var result []struct {
|
||||
ID string `bson:"tariffID"`
|
||||
}
|
||||
|
||||
filter := bson.D{
|
||||
{Key: fields.History.UserID, Value: userID},
|
||||
{Key: fields.History.IsDeleted, Value: false},
|
||||
@ -146,9 +147,13 @@ func (receiver *HistoryRepository) GetRecentTariffs(ctx context.Context, userID
|
||||
errors.ErrInternalError,
|
||||
)
|
||||
}
|
||||
tariffs := make([]string, len(result))
|
||||
for i, item := range result {
|
||||
tariffs[i] = item.ID
|
||||
tariffSet := make(map[string]struct{}, len(result))
|
||||
for _, item := range result {
|
||||
tariffSet[item.ID] = struct{}{}
|
||||
}
|
||||
tariffs := make([]string, 0, len(tariffSet))
|
||||
for tariff := range tariffSet {
|
||||
tariffs = append(tariffs, tariff)
|
||||
}
|
||||
return tariffs, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user