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

Fix garbage collection logic for small tables #280

Merged
merged 3 commits into from
May 1, 2018
Merged

Conversation

albertyw
Copy link
Member

This makes sure that there will be no IndexErrors when calling the garbage_collect method. I'm guessing this may be possible if there are fewer Requests than the target number of requests.

cc @avelis @drppi44

Replaces #279

Copy link
Collaborator

@avelis avelis left a comment

Choose a reason for hiding this comment

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

I am ok with the change. I did have a suggestion on potentially move the check with the line above. Since both if checks simply return it consolidates those statements into one.

silk/models.py Outdated
@@ -148,6 +148,8 @@ def garbage_collect(cls, force=False):
requests = cls.objects.order_by('-start_time')
if not requests:
return
if len(requests)-1 < target_count:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't we combine this line with the line above on 149? I know it lengthens the if check with an or but ensures only one return statement.

@albertyw
Copy link
Member Author

albertyw commented May 1, 2018

@avelis I made that update.

@avelis avelis merged commit e4536b3 into master May 1, 2018
@avelis
Copy link
Collaborator

avelis commented May 1, 2018

@albertyw Thanks!

@albertyw albertyw mentioned this pull request May 2, 2018
@drppi44
Copy link
Contributor

drppi44 commented May 4, 2018

thatnks!

@albertyw albertyw deleted the fix-index-error branch May 4, 2018 18:33
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