Usage Data Inconsistency in DB
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 88
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug (required)** A clear and concise description of what the bug is.
There is an inconsistency in the way we log data that makes running queries very complex.
For v1 API users, we have a concept of sessions - represented by `parentId != null`. For v0 API users, there is no concept of `parentId` (it's null by default).
This causes an issue for running weekly usage reports. For example, if you want to query for an user's usage over the past week, you need to run `parentId != null && createdAt == dateRange(lastWeek)` for v1 users, and `createdAt == dateRange(lastWeek)` for v0 users.
**Expected behavior (required)** A clear and concise description of what you expected to happen.
There is a consistent way to query for usage across different API versions. I would prefer `parentId != null && createdAt == dateRange(lastWeek)` for both. This means creating session objects for v0 users too.
**To Reproduce (required)** Steps to reproduce the behavior:
Run sql query to try and get usage data for all users in the last week.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the usage-data persistence and session creation paths for the v0 and v1 APIs, then trace how parentId and createdAt are recorded. Compare the resulting records with the weekly SQL query described in the issue. Done means v0 and v1 usage both expose session records that support the same parentId-based query, with tests or query validation covering both API versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100