-
Notifications
You must be signed in to change notification settings - Fork 850
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
[update]Add limit in api/events #742
Conversation
Signed-off-by: “fewdan” <[email protected]>
Signed-off-by: “fewdan” <[email protected]>
Signed-off-by: “fewdan” <[email protected]>
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.
@@ -73,27 +71,33 @@ type EventStore interface { | |||
|
|||
// Event represents an event instance. | |||
type Event struct { | |||
gorm.Model |
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.
Why gorm.Model
is not needed?
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.
The content in gorm.Model is "ID", "CreatedAt", "UpdatedAt", "DeletedAt". I took out these 4 things directly, so that it is convenient to add the "json" tag.
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.
Got it.
@@ -73,27 +71,33 @@ type EventStore interface { | |||
|
|||
// Event represents an event instance. | |||
type Event struct { | |||
gorm.Model |
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.
Got it.
) | ||
|
||
if filter.LimitStr != "" { |
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.
The two functions DryListByFilter
and ListByFilter
has many duplicates because they share the same logic, can we abstract some of them to another function?
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.
"DryListByFilter" is mainly used by grafana, and may be accessed more frequently than "ListByFilter". In order not to affect "ListByFilter", it is split out. To merge into the same function is not complicated to implement, mainly based on stability considerations.
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.
I am not saying to combine the two functions into one. But the two share some parts of duplicate code (except the pod records part). Is it okay to pull the duplicate part out and make it another function?
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.
But this actually is not part of this pr, so we can have an issue for it first and not do it in this pr. It depends on you
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.
Oh oh, I got it. I just got it wrong. Let me change it in the follow-up pr.
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
/merge |
Your auto merge job has been accepted, waiting for:
|
/run-all-tests |
* update Signed-off-by: “fewdan” <[email protected]> * update Signed-off-by: “fewdan” <[email protected]> * update Signed-off-by: “fewdan” <[email protected]> Co-authored-by: ti-srebot <[email protected]>
What problem does this PR solve?
Add "limit" in "api/events" to indicate the maximum length of events_list.