resolveUsageUser returns the authenticated user when present, otherwise the synthetic local user when auth is off. Centralizes the "if not auth, fall back to local" pattern that both routes need.
(c echo.Context, app *application.Application)
| 124 | // otherwise the synthetic local user when auth is off. Centralizes the |
| 125 | // "if not auth, fall back to local" pattern that both routes need. |
| 126 | func resolveUsageUser(c echo.Context, app *application.Application) *auth.User { |
| 127 | if u := auth.GetUser(c); u != nil { |
| 128 | return u |
| 129 | } |
| 130 | return app.FallbackUser() |
| 131 | } |
| 132 | |
| 133 | // usageResponse builds the JSON shape the UI consumes. The "viewer" |
| 134 | // field surfaces who the data belongs to so a single-user dashboard |
no test coverage detected