Aller au contenu
login
arrow_backRetour aux issues
Harsh-vardhan09/AthLead #104

Feat: Persist Latest User Input Values for Score Generation

ecoDébutant enhancement help wanted Backend Intermediate Open-to-All

descriptionDescription

### Description Currently, the values entered by the user in the **Generate Score / Get Score** form are not persisted in the backend. After redirect/navigation, the application loses the submitted input values and falls back to random/mock/static data. ## solution: - create an new mongoose schema for the user input data only persistent for user till new data is generated A backend persistence layer is needed to save the latest form input values entered by the user so they can be reused to populate: - Radar chart - Athlete metrics - Input fields - Score visualization Only the most recent submitted input values should be stored per user. --- ## Expected Behavior ### When User Clicks Generate Score Save the submitted input values in backend storage associated with the current user. Example fields: - Sport - Training Years - VO2 Max - HRV - Lactate Threshold - Stride Length - Cadence - Force Application - Performance Score - Adaptability Score --- ### When User Regenerates Score If the user submits new values: - Old input data should be replaced - Only the newest submitted input values should exist - Latest values should populate the UI after redirect/refresh --- ## Current Behavior - Form values are not persisted - Redirect causes loss of entered data - Radar chart uses mock/random/static values - Input values and chart data become inconsistent --- ## Required Backend Logic ### Save Latest Form Inputs Store only one latest input record per user. ### Replace Existing Inputs When new inputs are submitted: - overwrite previous values - no history/versioning required ### Fetch Latest Inputs Frontend should always receive: - latest submitted input values only --- ## Suggested Database Structure ### Table: `athlete_score_inputs` | Field | Type | |---|---| | id | UUID / ID | | user_id | Foreign Key | | sport | String | | training_years | Number | | vo2_max | Number | | hrv | Number | | lactate_threshold | Number | | stride_length | Number | | cadence | Number | | force_application | Number | | performance_score | Number | | adaptability_score | Number | | created_at | Timestamp | | updated_at | Timestamp | --- ## Suggested API Endpoints ### Save Latest Inputs ```http POST /api/score-inputs
codeOuvre sur GitHub