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

[Birthday] Cog model restructure #660

Open
wants to merge 1 commit into
base: V3/testing
Choose a base branch
from

Conversation

quachtridat
Copy link
Member

@quachtridat quachtridat commented Dec 11, 2023

Summary

Restructure cog Birthday according to #608. No functional changes expected.

Notes

Command handlers that utilize the MonthDayConverter now perform a "typing cast" to inform static type checkers that the birthday being passed to the command handlers as MonthDayConverter will be subsequently passed to the corresponding methods in CommandsCore as type datetime.datetime instead of MonthDayConverter. Note that Python typing cast does not change or restrict any functionalities because it is only information to static type checkers.

MonthDayConverter now exposes the InputType and OutputType as type aliases so that code utilizes the converted can be type-hinted better.

The birth year constant 2020 is moved to constants.py as DEFAULT_YEAR.

Tests

The testing for this PR is done a bit specially.

Automated testing will be done by #661, and manual testing will be gradually done within this PR's thread.

Help

image

Add birthday

image

image

After setting the role:

image

After the date display timeout:

image

Re-adding:

image

Channel

image

image

Delete

image

image

After setting the role:

image

List

image

After adding a birthday:

image

Role

image

image

Self

image

image

image

image

After enabling the self-birthday functionality:

image

(the above happens in DM)

Self birthday toggle

image

image

Test

image

Unassign

image

image

After setting the role:

image

Daily add

This tests the _dailyAdd function in Core. The local machine's time is manually adjusted to test this.

image

image

Daily sweep

This tests the _dailySweep function in Core. The local machine's time is manually adjusted to test this.

image

(the role is no longer there)

Restructure cog `Birthday` according to SFUAnime#608. No
functional changes expected.

Command handlers that utilize the `MonthDayConverter` now perform a
"typing cast" to inform static type checkers that the birthday being
passed to the command handlers as `MonthDayConverter` will be
subsequently passed to the corresponding methods in `CommandsCore` as
type `datetime.datetime` instead of `MonthDayConverter`. Note that
Python typing cast does not change or restrict any functionalities
because it is only information to static type checkers.

`MonthDayConverter` now exposes the `InputType` and `OutputType` as type
aliases so that code utilizes the converted can be type-hinted better.

The birth year constant 2020 is moved to `constants.py` as
`DEFAULT_YEAR`.
@quachtridat quachtridat added the refactor Umbrella label for refactoring efforts label Dec 11, 2023
@quachtridat quachtridat requested a review from a team December 11, 2023 13:34
@quachtridat quachtridat marked this pull request as ready for review December 17, 2023 06:34
Copy link
Member

@Injabie3 Injabie3 left a comment

Choose a reason for hiding this comment

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

Sorry this was long overdue, did a first pass.

Comment on lines +50 to +55
# Cancel the background task on cog unload.
def __unload(self): # pylint: disable=invalid-name
self.bgTask.cancel()

def cog_unload(self):
self.__unload()
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the __unload method and just leave cog_unload? I think this was ported from cog v2 days where it was looking for __unload(), so I don't think it's needed any more.

Suggested change
# Cancel the background task on cog unload.
def __unload(self): # pylint: disable=invalid-name
self.bgTask.cancel()
def cog_unload(self):
self.__unload()
def cog_unload(self):
self.bgTask.cancel()

cogs/birthday/commandHandlers.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Umbrella label for refactoring efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants