Worker: cheap 'rides newer than X' probe endpoint

Open Beginner friendly
#246 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
api, backend, database

Research direction

Start in worker.js with the sibling authenticated endpoints, resolveSession, and their CORS/OPTIONS handling. Add the GET /activities/newer-than endpoint using the specified activity count query and convert the since value from milliseconds to seconds. Verify dead sessions return 401, preflight works, and the response contains the expected count.

Written by the indexing model from the issue text.

Description

enhancement

The client-side merge UX for webhook auto-sync (epic #177) needs to know, on page load, whether D1 has rides the local IDB cache doesn't — without re-running the full /sync/recent loop.

Scope

GET /activities/newer-than?session=<token>&since=<unix-ms>

{ "count": <n> }
  • Resolve sessionathlete_id via the existing resolveSession (401 on a dead token, same as the other authed endpoints).
  • One query: SELECT COUNT(*) FROM activities WHERE user_id = ? AND has_power = 1 AND start_time > ? (note start_time is unix seconds in D1; since comes in as ms from the frontend's IDB shape — divide).
  • CORS + OPTIONS handling like the sibling endpoints in worker.js.

The frontend calls this with its max cached startTime; a non-zero count drives the notify toast / auto pull.

Part of #177.

Dominant language
JavaScript
Stars
0
Forks
0
Avg merge
1m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from iammike/power-predict

All issues in iammike/power-predict

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.