update protobuf

This commit is contained in:
Pavel 2024-04-25 20:44:32 +03:00
parent 2ecb506c79
commit 5863c5ec74
2 changed files with 11 additions and 10 deletions

@ -4,18 +4,25 @@ package codeword;
option go_package = "./codeword_rpc";
import "google/protobuf/empty.proto";
message Time {
int64 from = 1;
int64 to = 2;
}
service PromoCodeService {
rpc GetAllPromoActivations(Time) returns (PromoActivationResp);
rpc GetAllPromoActivations(google.protobuf.Empty) returns (PromoActivationResp);
}
message PromoActivationResp {
message UserTime {
string UserID = 1;
int64 Time = 2;
}
message Activations {
repeated string values = 1;
repeated UserTime values = 1;
}
map<string, Activations> response = 1;
}

@ -93,19 +93,12 @@ func (r *StatsRepository) GetAllPromoActivations(ctx context.Context, req *codew
{
"$unwind": "$usageArray.v",
},
{
"$match": bson.M{
"usageArray.v.time": bson.M{
"$gte": req.From,
"$lte": req.To,
},
},
},
{
"$group": bson.M{
"_id": "$_id",
"users": bson.M{"$push": bson.M{
"UserID": "$usageArray.v.userID",
"Time": "$usageArray.v.time",
}},
},
},
@ -122,6 +115,7 @@ func (r *StatsRepository) GetAllPromoActivations(ctx context.Context, req *codew
ID string `bson:"_id"`
Users []struct {
UserID string `bson:"UserID"`
Time int64
} `bson:"users"`
}
err := cursor.Decode(&data)