Skip to content
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

adding tests and logic #104

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rimonsh
Copy link
Collaborator

@rimonsh rimonsh commented May 16, 2023

What this PR does?

This PR I tested Poll suggestion Saving to django DB, whether it's in the past , or there's already a suggestion in the same time.

Notes for reviewer

I would be more than happy to hear more suggestions on how to check if suggested time is in the past (less than datetime.now() ).
For some reason, the line "if self.time < timezone.now():" is not passing.

Related Issue

Resolves #103

Test coverage

-Testing suggested time is not in the past.
-Testing that there's no other suggestion like it in the same poll.

@rimonsh rimonsh force-pushed the poll_suggestion_logic branch from 684a39d to 7c1b6ac Compare May 16, 2023 22:02
@Sendy459
Copy link
Collaborator

You can try to make them both offset naive :
by using .replace(tzinfo=None) before comparing
as I did in this func in Poll model.py file
def time_remaining(self):
remaining = self.end_time.replace(tzinfo=None) - timezone.localtime().replace(tzinfo=None)
if remaining < timedelta():
return timedelta()
return remaining

@rimonsh rimonsh force-pushed the poll_suggestion_logic branch from 878eb9b to 7d9d04a Compare May 18, 2023 13:19
@rimonsh rimonsh force-pushed the poll_suggestion_logic branch from 7d9d04a to 98c7574 Compare June 1, 2023 08:59
@rimonsh rimonsh requested a review from kobihk June 1, 2023 09:07
Copy link
Contributor

@rotem2022 rotem2022 left a comment

Choose a reason for hiding this comment

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

Overall looks good, I Just added a small idea

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe consider to add a field that tracks the number of votes each suggestion receives. This addition can provide valuable data for evaluating the popularity for each suggestion. Or you thought of alternative way for determining the chosen suggestion?

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.

Adding Poll Suggestion logic and test
5 participants