Merged
Conversation
…_id for get endpoint
|
✅ PR approval conditions satisfied (1 lead OR 2 team members approved). |
HeisSteve
reviewed
Mar 1, 2026
|
|
||
|
|
||
| // Handler for POST /api/sessions/{session_id}/time-label | ||
| // Receives a batch of time labels from the frontend after a session ends and stores them in the DB. |
Collaborator
There was a problem hiding this comment.
Also add a Get for the time-label as well, and similar to the get_eeg_data, allow the frontend to pass in a range
HeisSteve
reviewed
Mar 1, 2026
backend/api-server/src/main.rs
Outdated
| ) -> Result<Json<Vec<EegDataRow>>, (StatusCode, String)> { | ||
| info!("Received request to get EEG data for session {} from {} to {}", session_id, params.start, params.end); | ||
|
|
||
| match shared_logic::db::get_eeg_data_by_range(&app_state.db_client, session_id, params.start, params.end).await { |
Collaborator
There was a problem hiding this comment.
not a big issue, use add a use shared_logic::db::{get_earliest_eeg_timestamp,}; at the top so we don't need the shared_logic::db:: in shared_logic::db::get_eeg_data_by_range
HeisSteve
approved these changes
Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Implemented backend for label node feature. It includes a new database table to store event labels and 2 new api endpoints:
POST /api/sessions/:session_id/time-label - stores a batch of timestamped event labels after a session ends
GET /api/sessions/:session_id/eeg-data?start=...&end=... - retrieves EEG data rows within a given time range for a specific session
this branch also includes a cherry-picked commit from a teammate that adds session_id to the eeg_data table (required to filter EEG data by session). That commit brought an export endpoint along with it (not part of this feature, just a side effect of the cherry-pick)
Additional endpoint added to get time labels:
How?
Migration (add_time_labels.sql): creates time_labels table with id, session_id, timestamp, and label
Models added (models.rs):
DB functions (db.rs):
handlers + routes (main.rs):
3 new handler functions
Import cleanup:
Testing
Postman Testing:
Notes
the task board specified using timestamp as a foreign key to eeg_data but we stored it as a value instead, since a hard foreign key would require exact timestamp matches but it won't actually always match. The label timestamp is used as a reference point for the GET endpoint's time range query, which would better match the actual use case