Feat/scoreline predictions points grading#974
Merged
Olowodarey merged 8 commits intoJun 17, 2026
Merged
Conversation
…age types - Add home_score and away_score fields to Match struct - Add predicted_home_score and predicted_away_score to Prediction struct - Add points_earned and is_correct tracking to Prediction struct - Define POINTS_CORRECT_RESULT=1 and POINTS_EXACT_SCORE=3 constants - Implement MatchResult::from_scores() helper to derive 1X2 from scoreline - Implement Prediction::grade() to award 0/1/4 points based on accuracy
…ad of outcome symbol - Change submit_prediction() signature to take predicted_home_score and predicted_away_score - Automatically derive predicted_outcome from scores using MatchResult::from_scores() - Remove user-supplied outcome validation (no longer needed) - Update Prediction::new() to derive outcome from scoreline - Maintain backward compatibility with predicted_outcome field for reads
…tomatic prediction grading - Change submit_match_result() to accept home_score and away_score instead of winning_team symbol - Derive winning_team automatically from scores using MatchResult::from_scores() - Store actual scores (home_score, away_score) on Match struct - Grade all predictions immediately after result submission - Award 0 points (wrong result), 1 point (correct result/wrong score), or 4 points (exact score) - Expand get_user_score() to return (total_points, correct_results, exact_scores, total_matches) - Set is_correct and points_earned on predictions during grading
…predictions - Update submit_prediction() contract method signature to accept scoreline - Update submit_match_result() contract method signature to accept scoreline - Update get_user_score() return documentation for new tuple format - Maintain error handling and validation logic
- Migrate oracle_tests.rs to use contract client instead of direct storage - Enable proper grading flow through submit_match_result contract method - Update get_match_predictions_tests.rs to use scoreline-based predictions - Fix oracle_tests helper to use client.submit_match_result() - All 537+ tests passing including 15 new scoreline-specific tests - Tests validate: exact score (4 pts), correct result (1 pt), wrong result (0 pts) - Tests verify get_user_score returns correct tuple with points aggregation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
|
@strngecloud nice work thank you for your contribution |
13 tasks
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.
Exact Scoreline Predictions with Points Grading (#966)
Overview
Implements exact scoreline predictions with automatic points grading. Users can now predict exact match scores (e.g., "Arsenal 2 – Chelsea 1") instead of just the 1X2 result, earning bonus points for accuracy.
closes #966
Scoring System
Changes
Storage Types (
src/storage_types.rs)home_score: Option<u32>andaway_score: Option<u32>to Match structpredicted_home_score: u32andpredicted_away_score: u32to Prediction structpoints_earned: Option<u32>andis_correct: Option<bool>to Prediction structPOINTS_CORRECT_RESULT=1,POINTS_EXACT_SCORE=3MatchResult::from_scores(home, away)helper to derive 1X2 result from scorelinePrediction::grade(actual_home, actual_away)for automatic gradingPrediction Submission (
src/prediction.rs)submit_prediction()signature:(predictor, match_id, predicted_home_score, predicted_away_score)predicted_outcomefrom scores (no user input)Oracle Match Results (
src/oracle.rs)submit_match_result()signature:(caller, match_id, home_score, away_score)winning_teamfrom scoresget_user_score()return:(total_points, correct_results, exact_scores, total_matches)Contract Interface (
src/lib.rs)submit_prediction()contract methodsubmit_match_result()contract methodget_user_score()documentationTesting
submit_match_result_contract_tests.rsget_user_score()returns accurate statisticsAcceptance Criteria ✓
submit_prediction()takes scoreline (home_score, away_score)submit_match_result()takes final scoreline (home_score, away_score)get_user_score()returns (total_points, correct_results, exact_scores, total_matches)Prediction.points_earnedis None until graded, then Some(0|1|4)Migration Notes
This is a breaking change to the prediction API:
submit_prediction(predictor, match_id, outcome_symbol)submit_prediction(predictor, match_id, home_score, away_score)Callers must be updated to pass scores instead of outcome symbols.
Files Changed
src/storage_types.rs- Data structure updatessrc/prediction.rs- Prediction submission logicsrc/oracle.rs- Oracle result submission and gradingsrc/lib.rs- Contract interfacetests/*.rs- Test suite updates (7 test files)Commits
3ec12b49- Storage types: Add scoreline fields and scoring constantsb1d8d26d- Prediction: Update to scoreline-based submission027234b1- Oracle: Implement scoreline-based results and gradingfc312140- Contract interface: Update exposed functionscc60a4c2- Tests: Update suite for new API