-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AB#31036 On some requests in the export functionality, the same request + http parameters were being sent to the backend, even when the http parameters being used to make the request in the service were different. I started by changing the `generateQueryOptions` function to have an exhaustive list of query keys, thinking that the lack of `requestOptions` in this array was the culprit. It was not. So then I refactored the `HttpWrapper.performRequest` to only accept HttpParam _objects_ instead of HttpParam _class instances_. My thinking here was that tanstack-query was struggling to serialize class instances as opposed to objects. This was partially true, but did not solve the problem entirely. I ultimately added the `paginateQuery` option to the `generateQueryOptions`, because I realised that the issue was that the call to the Signal `paginateQuery` needed to happen _inside_ the `queryFn` in order to allow the "signals to signal". I'm not sure any of my thought process actually makes any sense, but hopefully you find the resulting code cleaner either way, given that now we don't have to worry about creating HttpParams anywhere anymore, and we just deal with objects.
- Loading branch information
Showing
11 changed files
with
165 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
interfaces/Portalicious/src/app/domains/metric/metric.api.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Injectable, Signal } from '@angular/core'; | ||
|
||
import { DomainApiService } from '~/domains/domain-api.service'; | ||
import { ProjectMetrics } from '~/domains/metric/metric.model'; | ||
|
||
const BASE_ENDPOINT = (projectId: Signal<number>) => [ | ||
'programs', | ||
projectId, | ||
'metrics', | ||
]; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class MetricApiService extends DomainApiService { | ||
getProjectSummaryMetrics(projectId: Signal<number>) { | ||
return this.generateQueryOptions<ProjectMetrics>({ | ||
path: [...BASE_ENDPOINT(projectId), 'program-stats-summary'], | ||
}); | ||
} | ||
|
||
public invalidateCache(projectId: Signal<number>): Promise<void> { | ||
return this.queryClient.invalidateQueries({ | ||
queryKey: this.pathToQueryKey(BASE_ENDPOINT(projectId)), | ||
}); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
interfaces/Portalicious/src/app/domains/metric/metric.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ProgramStats } from '@121-service/src/metrics/dto/program-stats.dto'; | ||
|
||
import { Dto } from '~/utils/dto-type'; | ||
// TODO: AB#30152 This type should be refactored to use Dto121Service | ||
export type ProjectMetrics = Dto<ProgramStats>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.