ai cooking
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

when did these users sign up (#409)

Co-authored-by: paul miller <paul.miller>

authored by

Paul Miller
paul miller
and committed by
GitHub
d5cf4737 4845220b

+19
+8
internal/users/admin_page.go
··· 18 18 type adminUserView struct { 19 19 ID string 20 20 Emails []string 21 + CreatedDate string 21 22 SavedRecipeCount int 22 23 CookedRecipeCount int 23 24 } ··· 37 38 <tr> 38 39 <th>User ID</th> 39 40 <th>Emails</th> 41 + <th>Created</th> 40 42 <th>Saved Recipe Count</th> 41 43 <th>Cooked Click Count</th> 42 44 </tr> ··· 56 58 none 57 59 {{end}} 58 60 </td> 61 + <td>{{.CreatedDate}}</td> 59 62 <td> 60 63 {{.SavedRecipeCount}} 61 64 </td> ··· 91 94 92 95 views := make([]adminUserView, 0, len(filtered)) 93 96 for _, user := range filtered { 97 + createdDate := "" 98 + if !user.CreatedAt.IsZero() { 99 + createdDate = user.CreatedAt.Format("2006-01-02") 100 + } 94 101 views = append(views, adminUserView{ 95 102 ID: user.ID, 96 103 Emails: append([]string(nil), user.Email...), 104 + CreatedDate: createdDate, 97 105 SavedRecipeCount: len(user.LastRecipes), 98 106 CookedRecipeCount: cookedRecipeCount(r.Context(), storage.cache, user), 99 107 })
+11
internal/users/admin_page_test.go
··· 22 22 if err := storage.Update(&utypes.User{ 23 23 ID: "2b190b35-10c6-4d6f-9858-3dd73c4155a0", 24 24 Email: []string{"legacy@example.com"}, 25 + CreatedAt: now.AddDate(0, 0, -10), 25 26 ShoppingDay: time.Monday.String(), 26 27 }); err != nil { 27 28 t.Fatalf("update legacy user: %v", err) ··· 30 31 if err := storage.Update(&utypes.User{ 31 32 ID: "user_1", 32 33 Email: []string{"alice@example.com"}, 34 + CreatedAt: time.Date(2026, time.March, 1, 15, 4, 5, 0, time.UTC), 33 35 ShoppingDay: time.Monday.String(), 34 36 LastRecipes: []utypes.Recipe{ 35 37 {Title: "Tomato Soup", Hash: "hash-1", CreatedAt: now}, ··· 42 44 if err := storage.Update(&utypes.User{ 43 45 ID: "user_2", 44 46 Email: []string{"bob@example.com", "bobby@example.com"}, 47 + CreatedAt: time.Date(2026, time.March, 2, 9, 30, 0, 0, time.UTC), 45 48 ShoppingDay: time.Tuesday.String(), 46 49 LastRecipes: []utypes.Recipe{ 47 50 {Title: "Pasta", Hash: "hash-3", CreatedAt: now}, ··· 91 94 } 92 95 if !regexp.MustCompile(`<td>\s*user_2\s*</td>[\s\S]*?<td>\s*1\s*</td>[\s\S]*?<td>\s*1\s*</td>`).MatchString(body) { 93 96 t.Fatalf("response body missing user_2 row with saved/cooked counts: %s", body) 97 + } 98 + for _, want := range []string{"2026-03-01", "2026-03-02"} { 99 + if !strings.Contains(body, want) { 100 + t.Fatalf("response body missing created date %q: %s", want, body) 101 + } 102 + } 103 + if strings.Contains(body, "0001-01-01") { 104 + t.Fatalf("response body should not include zero created date: %s", body) 94 105 } 95 106 if strings.Index(body, "user_1") > strings.Index(body, "user_2") { 96 107 t.Fatalf("expected users sorted by saved recipe count descending: %s", body)