@@ -15,11 +15,9 @@ import ( |
| 15 | "context" | 15 | "context" |
| 16 | "crypto/md5" //nolint:gosec // identicon hash, not a security primitive | 16 | "crypto/md5" //nolint:gosec // identicon hash, not a security primitive |
| 17 | "encoding/hex" | 17 | "encoding/hex" |
| 18 | - "errors" | | |
| 19 | "strings" | 18 | "strings" |
| 20 | "sync" | 19 | "sync" |
| 21 | | 20 | |
| 22 | - "github.com/jackc/pgx/v5" | | |
| 23 | "github.com/jackc/pgx/v5/pgxpool" | 21 | "github.com/jackc/pgx/v5/pgxpool" |
| 24 | | 22 | |
| 25 | usersdb "github.com/tenseleyFlow/shithub/internal/users/sqlc" | 23 | usersdb "github.com/tenseleyFlow/shithub/internal/users/sqlc" |
@@ -35,22 +33,22 @@ import ( |
| 35 | // unverified row. The handler should render the raw author name with | 33 | // unverified row. The handler should render the raw author name with |
| 36 | // a deterministic identicon fallback (IdenticonSeed). | 34 | // a deterministic identicon fallback (IdenticonSeed). |
| 37 | type Resolved struct { | 35 | type Resolved struct { |
| 38 | - User bool | 36 | + User bool |
| 39 | - UserID int64 | 37 | + UserID int64 |
| 40 | - Username string | 38 | + Username string |
| 41 | - DisplayName string | 39 | + DisplayName string |
| 42 | - AvatarURL string | 40 | + AvatarURL string |
| 43 | - IdenticonSeed string | 41 | + IdenticonSeed string |
| 44 | } | 42 | } |
| 45 | | 43 | |
| 46 | // Resolver resolves emails. Per-request memoization keeps a commits- | 44 | // Resolver resolves emails. Per-request memoization keeps a commits- |
| 47 | // list page (30 commits, often one author) to one DB query. Construct | 45 | // list page (30 commits, often one author) to one DB query. Construct |
| 48 | // per request; do not share across requests. | 46 | // per request; do not share across requests. |
| 49 | type Resolver struct { | 47 | type Resolver struct { |
| 50 | - pool *pgxpool.Pool | 48 | + pool *pgxpool.Pool |
| 51 | - q *usersdb.Queries | 49 | + q *usersdb.Queries |
| 52 | - cache map[string]Resolved | 50 | + cache map[string]Resolved |
| 53 | - mu sync.Mutex | 51 | + mu sync.Mutex |
| 54 | } | 52 | } |
| 55 | | 53 | |
| 56 | // New returns a fresh resolver tied to a pgx pool. Pass nil pool only | 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 | out.DisplayName = user.DisplayName | 89 | out.DisplayName = user.DisplayName |
| 92 | out.AvatarURL = "/avatars/" + user.Username | 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 | r.mu.Lock() | 97 | r.mu.Lock() |