@@ -15,11 +15,9 @@ import ( |
| 15 | 15 | "context" |
| 16 | 16 | "crypto/md5" //nolint:gosec // identicon hash, not a security primitive |
| 17 | 17 | "encoding/hex" |
| 18 | | - "errors" |
| 19 | 18 | "strings" |
| 20 | 19 | "sync" |
| 21 | 20 | |
| 22 | | - "github.com/jackc/pgx/v5" |
| 23 | 21 | "github.com/jackc/pgx/v5/pgxpool" |
| 24 | 22 | |
| 25 | 23 | usersdb "github.com/tenseleyFlow/shithub/internal/users/sqlc" |
@@ -35,22 +33,22 @@ import ( |
| 35 | 33 | // unverified row. The handler should render the raw author name with |
| 36 | 34 | // a deterministic identicon fallback (IdenticonSeed). |
| 37 | 35 | type Resolved struct { |
| 38 | | - User bool |
| 39 | | - UserID int64 |
| 40 | | - Username string |
| 41 | | - DisplayName string |
| 42 | | - AvatarURL string |
| 43 | | - IdenticonSeed string |
| 36 | + User bool |
| 37 | + UserID int64 |
| 38 | + Username string |
| 39 | + DisplayName string |
| 40 | + AvatarURL string |
| 41 | + IdenticonSeed string |
| 44 | 42 | } |
| 45 | 43 | |
| 46 | 44 | // Resolver resolves emails. Per-request memoization keeps a commits- |
| 47 | 45 | // list page (30 commits, often one author) to one DB query. Construct |
| 48 | 46 | // per request; do not share across requests. |
| 49 | 47 | type Resolver struct { |
| 50 | | - pool *pgxpool.Pool |
| 51 | | - q *usersdb.Queries |
| 52 | | - cache map[string]Resolved |
| 53 | | - mu sync.Mutex |
| 48 | + pool *pgxpool.Pool |
| 49 | + q *usersdb.Queries |
| 50 | + cache map[string]Resolved |
| 51 | + mu sync.Mutex |
| 54 | 52 | } |
| 55 | 53 | |
| 56 | 54 | // New returns a fresh resolver tied to a pgx pool. Pass nil pool only |
@@ -91,9 +89,9 @@ func (r *Resolver) Resolve(ctx context.Context, email string) Resolved { |
| 91 | 89 | out.DisplayName = user.DisplayName |
| 92 | 90 | out.AvatarURL = "/avatars/" + user.Username |
| 93 | 91 | } |
| 94 | | - } else if err != nil && !errors.Is(err, pgx.ErrNoRows) { |
| 95 | | - // log? handler-side concern; we just fall through. |
| 96 | 92 | } |
| 93 | + // Non-ErrNoRows errors fall through silently — logging is the |
| 94 | + // handler's call, the resolver just doesn't fill the row. |
| 97 | 95 | } |
| 98 | 96 | |
| 99 | 97 | r.mu.Lock() |