The statistics by actor should show the actuall number of people playing #1

Open
opened 2026-03-30 08:11:24 +00:00 by daniel · 0 comments
Owner

Problem

Currently, the statistics show "4 playing" when most of the players haven't played the first attempt yet. The property playing should only count the games with between 1 and 10 attempts (i.e., games started but not finished).

Current behavior

When a sentence is distributed to a player, a GameRecord is created with status: GameStatus::InProgress and attempts: Vec::new() (repository.rs:622-634). The get_sentence_stats() function (repository.rs:1007-1032) counts ALL InProgress games as playing:

GameStatus::InProgress => stats.playing += 1,

This includes games where attempts.len() == 0 — the player received the sentence but never opened the game or made any guess.

Proposed fix

Change the counting logic to distinguish between "not started" and "actually playing":

GameStatus::InProgress => {
    if record.attempts.len() > 0 {
        stats.playing += 1;
    }
}

This applies in two places:

  • get_sentence_stats() (line 1028)
  • get_all_sentence_stats() (line 1062)

The total count should also be reconsidered: should it include games that were never started? Two options:

  1. total counts all distributed games (current behavior) — then total > won + lost + playing because some are "not started".
  2. total counts only started games — then total == won + lost + playing.

Option 2 is cleaner for display. If option 1 is preferred, a new field not_started could make the count explicit.

Tests

#[test]
fn playing_excludes_zero_attempts() {
    // Create a game with no attempts (just distributed)
    let record_no_attempts = GameRecord {
        status: GameStatus::InProgress,
        attempts: vec![],
        ..default_record()
    };
    // Create a game with 2 attempts (actually playing)
    let record_playing = GameRecord {
        status: GameStatus::InProgress,
        attempts: vec![attempt(), attempt()],
        ..default_record()
    };

    // stats.playing should be 1, not 2
}

#[test]
fn playing_includes_games_with_attempts() {
    // A game with 5 attempts and still InProgress
    // should count as playing
}

#[test]
fn won_and_lost_not_affected() {
    // Won and Lost games should be counted regardless
    // of attempts.len() (they always have attempts > 0)
}

Affected files

  • src/repository.rsget_sentence_stats(), get_all_sentence_stats()
  • src/web/templates.rs — display may need adjustment if total semantics change
# Problem Currently, the statistics show "4 playing" when most of the players haven't played the first attempt yet. The property `playing` should only count the games with between 1 and 10 attempts (i.e., games started but not finished). # Current behavior When a sentence is distributed to a player, a `GameRecord` is created with `status: GameStatus::InProgress` and `attempts: Vec::new()` (`repository.rs:622-634`). The `get_sentence_stats()` function (`repository.rs:1007-1032`) counts ALL `InProgress` games as `playing`: ``` rust GameStatus::InProgress => stats.playing += 1, ``` This includes games where `attempts.len() == 0` — the player received the sentence but never opened the game or made any guess. # Proposed fix Change the counting logic to distinguish between "not started" and "actually playing": ``` rust GameStatus::InProgress => { if record.attempts.len() > 0 { stats.playing += 1; } } ``` This applies in two places: - `get_sentence_stats()` (line 1028) - `get_all_sentence_stats()` (line 1062) The `total` count should also be reconsidered: should it include games that were never started? Two options: 1. `total` counts all distributed games (current behavior) — then `total > won + lost + playing` because some are "not started". 2. `total` counts only started games — then `total == won + lost + playing`. Option 2 is cleaner for display. If option 1 is preferred, a new field `not_started` could make the count explicit. # Tests ``` rust #[test] fn playing_excludes_zero_attempts() { // Create a game with no attempts (just distributed) let record_no_attempts = GameRecord { status: GameStatus::InProgress, attempts: vec![], ..default_record() }; // Create a game with 2 attempts (actually playing) let record_playing = GameRecord { status: GameStatus::InProgress, attempts: vec![attempt(), attempt()], ..default_record() }; // stats.playing should be 1, not 2 } #[test] fn playing_includes_games_with_attempts() { // A game with 5 attempts and still InProgress // should count as playing } #[test] fn won_and_lost_not_affected() { // Won and Lost games should be counted regardless // of attempts.len() (they always have attempts > 0) } ``` # Affected files - `src/repository.rs` — `get_sentence_stats()`, `get_all_sentence_stats()` - `src/web/templates.rs` — display may need adjustment if `total` semantics change
daniel self-assigned this 2026-03-30 08:11:39 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
daniel/frases#1
No description provided.