-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci cd , record games and players to db #5
Conversation
WalkthroughThe recent update enhances a Telegram bot project, focusing on Docker integration, CI/CD via GitHub Actions, and database management for storing poll results and game data. Environment variables have been standardized, and error handling improved, ensuring smoother deployment and operation. This overhaul not only streamlines development workflows but also enriches the bot's functionality with better data handling and logging capabilities. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 4
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
docker-compose.yaml
is excluded by:!**/*.yaml
Files selected for processing (17)
- .dockerignore (1 hunks)
- .github/workflows/deploy.yml (2 hunks)
- .github/workflows/develop.yml (1 hunks)
- README.md (1 hunks)
- src/main.py (2 hunks)
- src/callbacks/receive_poll_answer.py (1 hunks)
- src/config.py (1 hunks)
- src/data_models/Game.py (1 hunks)
- src/data_models/Player.py (1 hunks)
- src/data_models/Record.py (1 hunks)
- src/db.py (1 hunks)
- src/get_handlers.py (1 hunks)
- src/handlers/error_handler.py (3 hunks)
- src/handlers/game.py (2 hunks)
- src/handlers/save.py (2 hunks)
- src/services/db_service.py (2 hunks)
- src/sql/init.sql (3 hunks)
Files skipped from review due to trivial changes (2)
- .dockerignore
- README.md
Additional comments: 13
src/get_handlers.py (1)
- 16-16: LGTM!
src/config.py (1)
- 10-14: LGTM!
src/__main__.py (1)
- 33-37: LGTM!
src/data_models/Record.py (1)
- 33-35: LGTM!
src/handlers/game.py (1)
- 35-39: LGTM!
.github/workflows/deploy.yml (1)
- 30-39: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [33-47]
LGTM!
src/callbacks/receive_poll_answer.py (1)
- 16-40: LGTM!
.github/workflows/develop.yml (1)
- 1-47: LGTM!
src/db.py (1)
- 10-10: LGTM!
src/sql/init.sql (1)
- 3-12: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [6-53]
LGTM!
src/handlers/error_handler.py (1)
- 38-50: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [25-50]
LGTM!
src/services/db_service.py (1)
- 25-64: LGTM!
src/handlers/save.py (1)
- 92-99: LGTM!
first_name: Optional[str | None] | ||
full_name: Optional[str | None] | ||
last_name: Optional[str | None] | ||
is_bot: Optional[bool] = False | ||
language_code: Optional[str | None] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the use of Optional[str | None]
is intentional. Typically, Optional[str]
suffices as it already implies None
can be a value, making the explicit | None
redundant.
- first_name: Optional[str | None]
+ first_name: Optional[str]
Apply this change to full_name
, last_name
, and language_code
as well.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
first_name: Optional[str | None] | |
full_name: Optional[str | None] | |
last_name: Optional[str | None] | |
is_bot: Optional[bool] = False | |
language_code: Optional[str | None] | |
first_name: Optional[str] | |
full_name: Optional[str] | |
last_name: Optional[str] | |
is_bot: Optional[bool] = False | |
language_code: Optional[str] |
@field_validator("is_bot", mode="after") | ||
@classmethod | ||
def validate_bot(cls, v: bool) -> str: | ||
return "TRUE" if v else "FALSE" # sqlite3 does not support boolean type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validate_bot
method's return type is incorrect. It should return bool
instead of str
to match the field type is_bot
. Adjust the method to directly return the boolean value.
- def validate_bot(cls, v: bool) -> str:
+ def validate_bot(cls, v: bool) -> bool:
- return "TRUE" if v else "FALSE"
+ return v
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
@field_validator("is_bot", mode="after") | |
@classmethod | |
def validate_bot(cls, v: bool) -> str: | |
return "TRUE" if v else "FALSE" # sqlite3 does not support boolean type | |
@field_validator("is_bot", mode="after") | |
@classmethod | |
def validate_bot(cls, v: bool) -> bool: | |
return v # sqlite3 does not support boolean type |
@field_validator("results", mode="after") | ||
@classmethod | ||
def validate_results(cls, v: dict) -> Literal["CH", "DH", "FW", "LW"]: | ||
outcomes = set(v.values()) | ||
if "I'm Canceler Hitler" in outcomes: | ||
return "CH" | ||
if "I'm Dead Hitler" in outcomes: | ||
return "DH" | ||
if "I'm Liberal Winner" in outcomes: | ||
return "LW" | ||
if "I'm Fascistic Winner" in outcomes: | ||
return "FW" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validate_results
method's return type should match the expected type of the results
attribute. If results
is intended to be a dict
, the method's return type and implementation need adjustment. Consider revising the method or the attribute type to ensure consistency.
- def validate_results(cls, v: dict) -> Literal["CH", "DH", "FW", "LW"]:
+ # Adjust the method or the attribute type to ensure consistency.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
@field_validator("results", mode="after") | |
@classmethod | |
def validate_results(cls, v: dict) -> Literal["CH", "DH", "FW", "LW"]: | |
outcomes = set(v.values()) | |
if "I'm Canceler Hitler" in outcomes: | |
return "CH" | |
if "I'm Dead Hitler" in outcomes: | |
return "DH" | |
if "I'm Liberal Winner" in outcomes: | |
return "LW" | |
if "I'm Fascistic Winner" in outcomes: | |
return "FW" | |
@field_validator("results", mode="after") | |
@classmethod | |
def validate_results(cls, v: dict): # Adjust the method or the attribute type to ensure consistency. | |
outcomes = set(v.values()) | |
if "I'm Canceler Hitler" in outcomes: | |
return "CH" | |
if "I'm Dead Hitler" in outcomes: | |
return "DH" | |
if "I'm Liberal Winner" in outcomes: | |
return "LW" | |
if "I'm Fascistic Winner" in outcomes: | |
return "FW" |
|
||
def main() -> None: | ||
if not config.TELEGRAM_BOT_TOKEN: | ||
raise ValueError("TELEGRAM_BOT_TOKEN env variable" "wasn't porpoused.") | ||
raise ValueError("TELEGRAM_BOT_TOKEN env variable" "wasn't purposed.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the error message concatenation is intentional. It appears there might be a missing space between "TELEGRAM_BOT_TOKEN env variable"
and "wasn't purposed."
- raise ValueError("TELEGRAM_BOT_TOKEN env variable" "wasn't purposed.")
+ raise ValueError("TELEGRAM_BOT_TOKEN env variable wasn't purposed.")
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
raise ValueError("TELEGRAM_BOT_TOKEN env variable" "wasn't purposed.") | |
raise ValueError("TELEGRAM_BOT_TOKEN env variable wasn't purposed.") |
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
.dockerignore
file to improve Docker image builds by excluding unnecessary directories.Chores
Refactor
Game
,Player
,Record
) including attribute renaming, new validation methods, and type adjustments for better data integrity and handling.