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

feat: add sorting for alerts #1097

Merged
merged 15 commits into from
May 2, 2024
Merged

feat: add sorting for alerts #1097

merged 15 commits into from
May 2, 2024

Conversation

VebjornG
Copy link
Contributor

@VebjornG VebjornG commented Apr 30, 2024

Make sorting alerts available in the frontend. We are going to fix the tests for creating a subscriber and subscription, as well as listing them, in a different PR.
Ticket

@neringaalt neringaalt requested a review from a team April 30, 2024 10:51
@VebjornG VebjornG marked this pull request as ready for review April 30, 2024 10:53
@VebjornG VebjornG requested a review from a team as a code owner April 30, 2024 10:53
Copy link
Contributor

@tuanng-cognite tuanng-cognite left a comment

Choose a reason for hiding this comment

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

Look good! Do we test it somehow?

@@ -50,10 +52,14 @@ export class AlertsAPI extends BaseResourceAPI<Alert> {
return this.createEndpoint(items);
};

public list = async (filter?: AlertFilterQuery) => {
return this.listEndpoint<AlertFilterQuery>(
public list = async (filter?: AlertFilterQuery, sort?: AlertSortQuery) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just use a single query property for this same as others?

export interface AlertFilterQuery extends FilterQuery {
  filter?: AlertFilter;
  sort?: WhateverSortTypeHere
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what i tried initially, but that didn't work for me because listEndpoint() expected two parameters, and not three, so i combined sort and filter so that i avoided changing listEndpoint()

@neringaalt
Copy link
Contributor

@VebjornG can you disable failing subscriber tests? We will fix them in another PR :)

Comment on lines 79 to 81
public sortAlerts = async (sort: AlertSortQuery) => {
return this.list(undefined, sort);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the meaning of this one? sort without the filter, or?

Copy link
Contributor Author

@VebjornG VebjornG May 2, 2024

Choose a reason for hiding this comment

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

Is such a function unnecessary if sorting is to be added? @polomani
If so I'm happy to remove it. I tried to follow the structure of the file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

sort and list are normally the same endpoint, hence it should be a single method as well.
I pushed a change

Copy link
Collaborator

@polomani polomani left a comment

Choose a reason for hiding this comment

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

Let's give this a bit more attention, the implementation is a bit misaligned with the other APIs in the SDK.
Also, I am not sure what is the point of sortAlerts function.

@VebjornG VebjornG requested a review from polomani May 2, 2024 08:32
@polomani polomani dismissed their stale review May 2, 2024 09:35

it's ok now

},
]);
} catch (error) {
expect((error as AxiosError).response?.status).toBe(400);
Copy link
Collaborator

Choose a reason for hiding this comment

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

the SDK never throws axios error directly. you should use CogniteError

@VebjornG VebjornG requested a review from polomani May 2, 2024 11:08
@VebjornG VebjornG merged commit 1a08cca into master May 2, 2024
11 checks passed
@VebjornG VebjornG deleted the vebjorn/add-sort-alerts branch May 2, 2024 12:58
This pull request was closed.
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.

4 participants