Git Product home page Git Product logo

secret-hitler-telegram-bot-statistic-collector's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

zimfv

secret-hitler-telegram-bot-statistic-collector's Issues

Investigate incorrect stat in db and resolve conflicts

  1. Invalid Player Distribution with Usernames
SELECT r.game_id,
       p.username,
       CASE 
           WHEN r.role IN ('HC', 'DH', 'HL', 'HW') THEN 'Hitler'
           WHEN r.role IN ('LW', 'LL') THEN 'Liberal'
           WHEN r.role IN ('FW', 'FL') THEN 'Fascist'
       END AS role
FROM records r
INNER JOIN players p ON r.player_id = p.id
WHERE r.game_id IN (
    SELECT game_id
    FROM records
    GROUP BY game_id
    HAVING SUM(CASE WHEN role IN ('HC', 'DH', 'HL', 'HW') THEN 1 ELSE 0 END) > 1
        OR SUM(CASE WHEN role IN ('LW', 'LL') THEN 1 ELSE 0 END) > 6
        OR SUM(CASE WHEN role IN ('FW', 'FL', 'HC', 'DH', 'HL', 'HW') THEN 1 ELSE 0 END) > 4
)
ORDER BY r.game_id;

This query selects games with invalid player distributions and displays the game ID, the usernames of the players involved, and their roles in a more human-readable format.

2. Games with Mutually Exclusive Victory Conditions with Usernames

SELECT DISTINCT r.game_id, p.username, 
    CASE 
        WHEN r.role IN ('LW', 'DH', 'FL', 'HL') THEN 'Liberal Win Condition'
        WHEN r.role IN ('FW', 'HW', 'HC', 'LL') THEN 'Fascist Win Condition'
    END AS win_condition
FROM records r
INNER JOIN players p ON r.player_id = p.id
WHERE r.game_id IN (
    SELECT game_id FROM records WHERE role IN ('LW', 'DH', 'FL', 'HL')
    INTERSECT
    SELECT game_id FROM records WHERE role IN ('FW', 'HW', 'HC', 'LL')
)
ORDER BY r.game_id;

This query identifies games where there are winners from both the Liberal and Fascist sides, which should not be possible according to the rules. It lists the game ID, the usernames of the players involved, and the type of win condition they contributed to (Liberal or Fascist).

The updated `save` function includes a comprehensive approach to processing and saving game records, as well as handling additional post-game tasks such as deleting messages and sending a photo with game results. This enhances the game's interactivity and user engagement. However, ensure that error handling is in place for each asynchronous operation within `asyncio.gather` to gracefully handle any failures.

          The updated `save` function includes a comprehensive approach to processing and saving game records, as well as handling additional post-game tasks such as deleting messages and sending a photo with game results. This enhances the game's interactivity and user engagement. However, ensure that error handling is in place for each asynchronous operation within `asyncio.gather` to gracefully handle any failures.

Consider adding try-except blocks around operations that might fail, such as save_record, save_game, and context.bot.send_photo, to ensure the application remains robust and user-friendly even when unexpected errors occur.

Originally posted by @coderabbitai[bot] in #10 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.