diff --git a/internal/repository/promocode_stats.go b/internal/repository/promocode_stats.go index 2d96c3d..94467c8 100644 --- a/internal/repository/promocode_stats.go +++ b/internal/repository/promocode_stats.go @@ -79,7 +79,7 @@ func (r *StatsRepository) GetStatistics(ctx context.Context, promoCodeID string) return promoCodeStats, nil } -func (r *StatsRepository) GetAllPromoActivations(ctx context.Context, req *codeword_rpc.Time) (*codeword_rpc.PromoActivationResp, error) { +func (r *StatsRepository) GetAllPromoActivations(ctx context.Context) (*codeword_rpc.PromoActivationResp, error) { pipeline := []bson.M{ { "$project": bson.M{ @@ -128,7 +128,10 @@ func (r *StatsRepository) GetAllPromoActivations(ctx context.Context, req *codew } for _, user := range data.Users { - result[data.ID].Values = append(result[data.ID].Values, user.UserID) + result[data.ID].Values = append(result[data.ID].Values, &codeword_rpc.PromoActivationResp_UserTime{ + UserID: user.UserID, + Time: user.Time, + }) } } diff --git a/internal/services/promocode_service.go b/internal/services/promocode_service.go index fdc8c24..5633682 100644 --- a/internal/services/promocode_service.go +++ b/internal/services/promocode_service.go @@ -12,6 +12,7 @@ import ( "fmt" "go.mongodb.org/mongo-driver/bson/primitive" "go.uber.org/zap" + "google.golang.org/protobuf/types/known/emptypb" "time" ) @@ -29,7 +30,7 @@ type PromoCodeRepository interface { type PromoStatsRepository interface { UpdateStatistics(ctx context.Context, req *models.ActivateReq, promoCode *models.PromoCode, userID string) error GetStatistics(ctx context.Context, promoCodeID string) (models.PromoCodeStats, error) - GetAllPromoActivations(ctx context.Context, req *codeword_rpc.Time) (*codeword_rpc.PromoActivationResp, error) + GetAllPromoActivations(ctx context.Context) (*codeword_rpc.PromoActivationResp, error) } type PromoDeps struct { @@ -272,8 +273,8 @@ func (s *PromoCodeService) GetStats(ctx context.Context, req models.PromoStatReq return resp, nil } -func (s *PromoCodeService) GetAllPromoActivations(ctx context.Context, req *codeword_rpc.Time) (*codeword_rpc.PromoActivationResp, error) { - result, err := s.statsRepo.GetAllPromoActivations(ctx, req) +func (s *PromoCodeService) GetAllPromoActivations(ctx context.Context, _ *emptypb.Empty) (*codeword_rpc.PromoActivationResp, error) { + result, err := s.statsRepo.GetAllPromoActivations(ctx) if err != nil { s.logger.Error("error getting all promo activations data", zap.Error(err)) return nil, err