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

[update]Add limit in api/events #742

Merged
merged 4 commits into from
Jul 29, 2020
Merged

[update]Add limit in api/events #742

merged 4 commits into from
Jul 29, 2020

Conversation

fewdan
Copy link
Member

@fewdan fewdan commented Jul 27, 2020

What problem does this PR solve?

Add "limit" in "api/events" to indicate the maximum length of events_list.

fewdan added 3 commits July 27, 2020 15:55
Signed-off-by: “fewdan” <[email protected]>
Signed-off-by: “fewdan” <[email protected]>
Signed-off-by: “fewdan” <[email protected]>
Copy link
Member

@g1eny0ung g1eny0ung left a 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
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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
Copy link
Contributor

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 != "" {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member

@cwen0 cwen0 left a comment

Choose a reason for hiding this comment

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

LGTM

@cwen0
Copy link
Member

cwen0 commented Jul 29, 2020

/merge

@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 751

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit ca142f1 into chaos-mesh:master Jul 29, 2020
@fewdan fewdan deleted the add_limit branch July 29, 2020 08:37
sjwsl pushed a commit to sjwsl/chaos-mesh that referenced this pull request May 6, 2021
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants