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

Issues/525 fix management command inconsistency #527

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kaushikaryan04
Copy link

As mentioned in the issue I have changed the delete_old_radiusbatch_users argument to take in days instead of months and have changed the tasks and tests accordingly.

kaushikaryan04 and others added 4 commits June 30, 2024 16:59
…ent openwisp#525

changed the delete_old_radiusbatch_users management command to use days instead of months also modified tasks and tests to use days.

Fixes openwisp#525
… instead of months openwisp#525

Changed the delete_old_radiusbatch_users command to take in days in argument instead of months and modified tests and tasks accordingly.

Fixes openwisp#525
@coveralls
Copy link

Coverage Status

coverage: 98.678%. remained the same
when pulling 5283833 on kaushikaryan04:issues/525-fix-management-command-inconsistency
into 3303ae1 on openwisp:master.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Thank you for contributing @kaushikaryan04.

The current changes woulbe backward incompatible and can break existing instances.
We should implement this change in a backward compatible way:

  • We should not remove the --older-than-months options from the code
  • We should give precedence to --older-than-days and use the old option only if --older-than-days is not present
  • We should update the documentation too (do a project wide search for delete_old_radiusbatch_users to find it, it's in docs/source/user/management_commands.rst`

So, both older-than-days and older-than-months should be optional but we must ensure there's at least one supplied or we should return an error.

… as well openwisp#525

Added the option to delete users by specifying days or months.If nothing is provided 18 months will be taken as default.

Fixes openwisp#525
@kaushikaryan04
Copy link
Author

kaushikaryan04 commented Jul 9, 2024

I think this should be good. All old features are working as they were before and --older-than-days is added as well. Documentation also updated.

@coveralls
Copy link

coveralls commented Jul 9, 2024

Coverage Status

coverage: 98.681% (+0.002%) from 98.679%
when pulling a9af7a0 on kaushikaryan04:issues/525-fix-management-command-inconsistency
into fd8a230 on openwisp:master.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

@kaushikaryan04 looks good, I found something that doesn't convince me, please see my comment below.

parser.add_argument(
'--older-than-months',
action='store',
type=int,
default=BATCH_DELETE_EXPIRED,
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 update the default so that it's used only on the new argument? The default for this old argument should be None, so that the new argument will be used by default.

Copy link
Author

Choose a reason for hiding this comment

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

Yes this could be done but the action would be same if no argument is provided that is why I did not changed it.I can do this in the next commit.

@@ -43,9 +43,9 @@ def deactivate_expired_users():


@shared_task
def delete_old_radiusbatch_users(older_than_months=12):
def delete_old_radiusbatch_users(older_than_days=365):
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the default here be the same as BATCH_DELETE_EXPIRED? This was probably a mistake.

Copy link
Author

Choose a reason for hiding this comment

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

Sure we can change this

@@ -174,7 +174,7 @@ def test_delete_old_radiusbatch_users_command(self):
self.assertEqual(get_user_model().objects.all().count(), 6)
call_command('delete_old_radiusbatch_users')
self.assertEqual(get_user_model().objects.all().count(), 3)
call_command('delete_old_radiusbatch_users', older_than_months=12)
call_command('delete_old_radiusbatch_users', older_than_days=365)
Copy link
Member

Choose a reason for hiding this comment

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

We need a test that ensures the old behavior continues to work.

Copy link
Author

Choose a reason for hiding this comment

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

Sure I can add some more users to test.

kaushikaryan04 and others added 2 commits July 19, 2024 12:02


Made the suggested changes and added the testcase so both old and new command could be tested.

Fixes openwisp#525
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