-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add Pagination to Listing Projects for Housekeeping #587
Add Pagination to Listing Projects for Housekeeping #587
Conversation
Codecov Report
@@ Coverage Diff @@
## main #587 +/- ##
==========================================
- Coverage 51.11% 50.89% -0.22%
==========================================
Files 66 69 +3
Lines 7008 7167 +159
==========================================
+ Hits 3582 3648 +66
- Misses 2952 3035 +83
- Partials 474 484 +10
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
I left a small request for you.
Since HousekeepingProjectFetchSize
option is newly introduced, we need to add this option to the CLI flag.
Ref: #512
834033e
to
e20e17c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
I left a comment.
No worries at the moment since we have small projects in However, as our services grow, this could become problematic when fetching the first page. To address this potential issue, we could consider changing the interface and implementing it with keyset pagination. For more information on this approach, you can check out: https://use-the-index-luke.com/no-offset |
cfd3d0b
to
2b58225
Compare
To avoid all project info being loaded from DB, pagination is added for projects and perform housekeeping in smaller portions. * Add HousekeepingProjectFetchSize in config Fix checking the last page Add housekeeping project fetch size option to the CLI flag * set project fetch size to 100 in config.sample.yml fix lint Move housekeepingProjectPage variable into the Housekeeping.run function Add keyset pagination to find projects * update housekeeping test not to set project id to zero value
2b58225
to
a271e36
Compare
@hackerwins I changed the database interface like you mentioned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyset pagination looks awesome!
I left some small comments with my personal questions.
* Cleanup code * add pagination test for memory db Cleanup test
5a845cc
to
9fec852
Compare
* add test code for mongo client * clean up test code
6761e9f
to
3ff9d60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for applying my requests.
I left one more comment about using indexes in MemDB.
There was a problem hiding this 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 left minor style-related comments.
} | ||
|
||
func createDBandProjects(t *testing.T) (*memory.DB, []*database.ProjectInfo) { | ||
t.Helper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first time to see t.Helper
. When is this useful? Would it be good to add t.Helper
to other helper functions too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Helper()
indicates to the Go test runner thatcreateDBandProjects()
helper function is a test helper. It makes it easy to report test failures at the call site of the parent function rather than the call site oft.Error()
andt.Errorf()
. When t.Error() is called fromcreateDBandProjects()
function, the Go test runner will report the filename and line number of the code which called thecreateDBandProjects()
function in the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
* Add Pagination to Listing Projects for Housekeeping To avoid all project info being loaded from DB, pagination is added for projects and perform housekeeping in smaller portions. * Add HousekeepingProjectFetchSize in config Add housekeeping project fetch size option to the CLI flag * set project fetch size to 100 in config.sample.yml Move housekeepingProjectPage variable into the Housekeeping.run function Add keyset pagination to find projects * update housekeeping test not to set project id to zero value
What this PR does / why we need it:
To avoid all project info being loaded from DB when doing housekeeping, pagination is added for listing projects and performing housekeeping in smaller portions.
Which issue(s) this PR fixes:
Fixes #569
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist: