-
Notifications
You must be signed in to change notification settings - Fork 20
feat/add-real-time-alerts-for-new-issues #20
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
base: main
Are you sure you want to change the base?
Conversation
iamnovichek
left a comment
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.
Nice begin
tracker/tasks.py
Outdated
|
|
||
|
|
||
| @app.on_after_configure.connect | ||
| def check_for_new_issues(sender, **kwargs): |
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.
add types annotation, docstrings
tracker/tasks.py
Outdated
| print(arg) | ||
|
|
||
|
|
||
| def get_relevant_recipients(repositories: list) -> dict[str, list]: |
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.
add docstring
tracker/tasks.py
Outdated
| subscribed_users = TelegramUser.objects.filter( | ||
| notify_about_new_issues=True, | ||
| user__repository__name__in=repositories # Assuming 'name' identifies the repositories. | ||
| ).distinct() |
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.
We do not need distinct here
tracker/tasks.py
Outdated
| user_repo_map = {} | ||
|
|
||
| for telegram_user in subscribed_users: | ||
| repositories = Repository.objects.filter(user=telegram_user.user, name__in=repositories) |
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.
Did you test it? It guess it's gonna shadow the param repositories in this function
tracker/tasks.py
Outdated
| for telegram_user in subscribed_users: | ||
| repositories = Repository.objects.filter(user=telegram_user.user, name__in=repositories) | ||
|
|
||
| print(f"Telegram User: {telegram_user.telegram_id}") |
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.
please use logger
tracker/telegram/bot.py
Outdated
| @dp.message(Command("notify_about_new_issues")) | ||
| async def subscribe_to_issue_notifications(msg: Message): | ||
| try: | ||
| telegram_user = TelegramUser.objects.get(telegram_id=msg.from_user.id) |
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.
Use filter(...).first() instead of get. That way you won't get an exception. Just None if it doesn't exist
core/settings.py
Outdated
|
|
||
| # SECURITY WARNING: don't run with debug turned on in production! | ||
| DEBUG = False | ||
| DEBUG = True |
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.
move it to env file, don't forget to add it to env.example
|
|
||
|
|
||
| @dp.message(Command("notify_about_new_issues")) | ||
| async def subscribe_to_issue_notifications(msg: Message): |
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.
add docstring
No description provided.