Course lesson 57 · Wrapping Up
Completing the User Application Dashboard
The dashboard’s placeholder statistics are replaced with account-filtered database queries exposed through existing tRPC routes. The queries calculate recently active links, click counts over several windows, and country breakdowns. The final UI cleanup supplies the frontend build variable used to construct clickable short-link URLs.
Primary source: course video 57 · Supplied English subtitles · 00:09:19.
Understand the idea
- Active links means links clicked in the last hour, grouped by link identity and name, with counts and latest click time.
- Every analytics query is scoped to the authenticated account or user.
- Conditional aggregation can calculate 24-hour and 48-hour metrics while scanning the broader 48-hour window once.
- Country grouping turns raw click events into counts and shares of the overall total.
- A frontend environment variable is compiled into the link display, so both local and automated builds need its value.
What the course does
- Add an active-links query filtered by time and account, then connect it to the corresponding tRPC handler.
- Click a real short link and verify that the dashboard shows its count and recent activity time.
- Add total counts for the last hour, 24/48 hours, and 30 days.
- Add the 30-day country grouping and replace remaining mock endpoint responses.
- Pass authenticated user identity from tRPC context into every new query.
- Set the frontend backend-host variable locally and in stage and production build settings to replace undefined displayed URLs.
Watch for
- The instructor notes that very large click volumes may need a more suitable analytics storage design than these direct D1 scans.
- Several time-window queries repeat logic; parameterizing the shared pattern is discussed but not implemented.
- The video uses go-stage/go host examples after the earlier /r/ route demonstration; added advice: choose one consistent deployed URL convention.
Recall before revealing
Why must analytics queries use the user ID from tRPC context?
Reveal the explanation
That context contains the authenticated identity, allowing results to be restricted to the requesting user’s account.
Try it
Define expected dashboard results for two users whose links receive different clicks in the last hour.
Check your result
Your expected counts, active links, and country breakdowns remain separated by account.
Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.
Rewatch only what you need
Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.
- 00:01:02 — Active links grouped by recent clicks
- 00:04:03 — Combined 24-hour and 48-hour aggregation
- 00:05:34 — Country breakdown query
- 00:07:05 — Fix the undefined short-link host
Companion primary documentation: Cloudflare Workers Vitest integration. For recorded API names, commands, limits, and prices, check the version you use.