Skip to content

feat/add-real-time-alerts-for-new-issues#20

Draft
UzNaZ wants to merge 10 commits intomainfrom
feat/add-real-time-alerts-for-new-issues
Draft

feat/add-real-time-alerts-for-new-issues#20
UzNaZ wants to merge 10 commits intomainfrom
feat/add-real-time-alerts-for-new-issues

Conversation

@UzNaZ
Copy link
Copy Markdown
Collaborator

@UzNaZ UzNaZ commented Nov 20, 2024

No description provided.

Copy link
Copy Markdown
Collaborator

@iamnovichek iamnovichek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice begin

Comment thread core/celery.py Outdated
Comment thread tracker/models.py Outdated
Comment thread tracker/tasks.py Outdated
Comment thread tracker/tasks.py Outdated
Comment thread tracker/tasks.py Outdated


@app.on_after_configure.connect
def check_for_new_issues(sender, **kwargs):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add types annotation, docstrings

Comment thread tracker/tasks.py Outdated
print(arg)


def get_relevant_recipients(repositories: list) -> dict[str, list]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstring

Comment thread 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()
Copy link
Copy Markdown
Collaborator

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

Comment thread tracker/tasks.py Outdated
user_repo_map = {}

for telegram_user in subscribed_users:
repositories = Repository.objects.filter(user=telegram_user.user, name__in=repositories)
Copy link
Copy Markdown
Collaborator

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

Comment thread 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}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use logger

Comment thread 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)
Copy link
Copy Markdown
Collaborator

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

@djeck1432 djeck1432 self-requested a review November 20, 2024 18:27
Comment thread tracker/models.py Outdated
Comment thread core/settings.py Outdated

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True
Copy link
Copy Markdown
Collaborator

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

Comment thread tracker/telegram/bot.py


@dp.message(Command("notify_about_new_issues"))
async def subscribe_to_issue_notifications(msg: Message):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants