Skip to content

Conversation

@UzNaZ
Copy link
Collaborator

@UzNaZ UzNaZ commented Nov 20, 2024

No description provided.

Copy link
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

tracker/tasks.py Outdated


@app.on_after_configure.connect
def check_for_new_issues(sender, **kwargs):
Copy link
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

tracker/tasks.py Outdated
print(arg)


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

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()
Copy link
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

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
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

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
Collaborator

Choose a reason for hiding this comment

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

please use logger

@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
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
core/settings.py Outdated

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True
Copy link
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



@dp.message(Command("notify_about_new_issues"))
async def subscribe_to_issue_notifications(msg: Message):
Copy link
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.

4 participants