This commit is contained in:
Till Faelligen 2023-03-01 15:09:10 +01:00
parent f1ccfcf150
commit 1aa70b0f56
No known key found for this signature in database
GPG Key ID: 3DF82D8AB9211D4E

View File

@ -187,8 +187,8 @@ func Test_UserStatistics(t *testing.T) {
})
t.Run("Users not active for one/two month", func(t *testing.T) {
mustUpdateDeviceLastSeen(t, ctx, db, "user1", time.Now().AddDate(0, -2, 0))
mustUpdateDeviceLastSeen(t, ctx, db, "user2", time.Now().AddDate(0, -1, 0))
mustUpdateDeviceLastSeen(t, ctx, db, "user1", time.Now().AddDate(0, 0, -60))
mustUpdateDeviceLastSeen(t, ctx, db, "user2", time.Now().AddDate(0, 0, -30))
gotStats, _, err := statsDB.UserStatistics(ctx, nil)
if err != nil {
t.Fatalf("unexpected error: %v", err)
@ -224,9 +224,9 @@ func Test_UserStatistics(t *testing.T) {
- Where account creation and last_seen are > 30 days apart
*/
t.Run("R30Users tests", func(t *testing.T) {
mustUserUpdateRegistered(t, ctx, db, "user1", time.Now().AddDate(0, -2, 0))
mustUserUpdateRegistered(t, ctx, db, "user1", time.Now().AddDate(0, 0, -60))
mustUpdateDeviceLastSeen(t, ctx, db, "user1", time.Now())
mustUserUpdateRegistered(t, ctx, db, "user4", time.Now().AddDate(0, -2, 0))
mustUserUpdateRegistered(t, ctx, db, "user4", time.Now().AddDate(0, 0, -60))
mustUpdateDeviceLastSeen(t, ctx, db, "user4", time.Now())
startTime := time.Now().AddDate(0, 0, -2)
err := statsDB.UpdateUserDailyVisits(ctx, nil, startTime, startTime.Truncate(time.Hour*24))