Skip to content

Add /v1/usage endpoint and scheduler toggle - #286

Merged
khoroshevskyi merged 2 commits into
devfrom
feat/usage-endpoint
Aug 24, 2026
Merged

Add /v1/usage endpoint and scheduler toggle#286
khoroshevskyi merged 2 commits into
devfrom
feat/usage-endpoint

Conversation

@nsheff

@nsheff nsheff commented Aug 22, 2026

Copy link
Copy Markdown
Member

What this does

Adds a public read-only endpoint to get BEDbase usage counts by date range, and a switch to run the server without writing usage data.

GET /v1/usage

Returns per-item usage counts for one event type (files, bed_meta, bedset_meta, bed_search, bedset_search), optionally filtered to a date window, with paging. Unlike the existing /detailed-usage (top 20, all-time only), this exposes the full, time-filterable data, which lets the stats site report accurate per-month usage.

BEDHOST_DISABLE_USAGE_SCHEDULER

New environment flag. When set, the hourly usage-flush scheduler does not start, so the server can be pointed at a database in read-only mode (useful for local inspection against production data). Default behavior is unchanged (scheduler on).

Depends on

databio/bbconf#126 — this endpoint calls the new bbagent.get_usage and imports UsageResponse from bbconf. Merge and release bbconf first; CI here will pass once bedhost picks up that bbconf version.

@nsheff
nsheff force-pushed the feat/usage-endpoint branch from 4a8c93a to 4a91b5d Compare August 22, 2026 20:19
@nsheff
nsheff requested a balanced review from Copilot August 22, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nsheff
nsheff requested a balanced review from Copilot August 22, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread bedhost/routers/base_api.py Outdated
Comment thread bedhost/routers/base_api.py
Comment thread bedhost/main.py
Change async def to def so FastAPI runs the blocking DB call in
a threadpool; cap limit at 1000 to bound response size.
@khoroshevskyi
khoroshevskyi merged commit 8aaab63 into dev Aug 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants