@@ -163,34 +163,37 @@ func (q *fakeQuerier) GetTemplateDAUs(_ context.Context, templateID uuid.UUID) (
163163 q .mutex .Lock ()
164164 defer q .mutex .Unlock ()
165165
166- counts := make (map [time.Time ]map [string ]struct {})
166+ seens := make (map [time.Time ]map [uuid. UUID ]struct {})
167167
168168 for _ , as := range q .agentStats {
169169 if as .TemplateID != templateID {
170170 continue
171171 }
172172
173173 date := as .CreatedAt .Truncate (time .Hour * 24 )
174- dateEntry := counts [date ]
174+
175+ dateEntry := seens [date ]
175176 if dateEntry == nil {
176- dateEntry = make (map [string ]struct {})
177+ dateEntry = make (map [uuid. UUID ]struct {})
177178 }
178- counts [date ] = dateEntry
179-
180- dateEntry [as .UserID .String ()] = struct {}{}
179+ dateEntry [as .UserID ] = struct {}{}
180+ seens [date ] = dateEntry
181181 }
182182
183- countKeys := maps .Keys (counts )
184- sort .Slice (countKeys , func (i , j int ) bool {
185- return countKeys [i ].Before (countKeys [j ])
183+ seenKeys := maps .Keys (seens )
184+ sort .Slice (seenKeys , func (i , j int ) bool {
185+ return seenKeys [i ].Before (seenKeys [j ])
186186 })
187187
188188 var rs []database.GetTemplateDAUsRow
189- for _ , key := range countKeys {
190- rs = append (rs , database.GetTemplateDAUsRow {
191- Date : key ,
192- Amount : int64 (len (counts [key ])),
193- })
189+ for _ , key := range seenKeys {
190+ ids := seens [key ]
191+ for id := range ids {
192+ rs = append (rs , database.GetTemplateDAUsRow {
193+ Date : key ,
194+ UserID : id ,
195+ })
196+ }
194197 }
195198
196199 return rs , nil
0 commit comments