From 1b06ee7623372c89b2e79ec851587d2761f44227 Mon Sep 17 00:00:00 2001 From: Georg Dangl Date: Fri, 1 Jul 2022 17:41:05 +0200 Subject: [PATCH 1/6] Exclude test projects from coverage --- build/Build.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/build/Build.cs b/build/Build.cs index 3eeb18a..e72a86b 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -174,6 +174,7 @@ void SendTeamsMessage(string title, string message, bool isError) .SetCoverletOutput($"{OutputDirectory / projectName}_coverage.xml") .SetProcessArgumentConfigurator(a => a .Add($"/p:Include=[LightQuery*]*") + .Add($"/p:Exclude=[*Test*]*") .Add($"/p:ExcludeByAttribute=\\\"Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute\\\"") // This part is required to ensure that xUnit isn't using app domains or shadow copying, since coverlet // needs to modify the dlls to collect coverage. See here for more information: From 93f697ede2273ef0c5b649029be50e8f47a77405 Mon Sep 17 00:00:00 2001 From: ruslan-minukov Date: Wed, 3 Aug 2022 14:00:09 +0300 Subject: [PATCH 2/6] feat: changed method getAll --- .../ng-lightquery/src/lib/pagination-base.service.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.ts b/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.ts index 3444155..e3bcb84 100644 --- a/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.ts +++ b/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.ts @@ -160,7 +160,7 @@ export abstract class PaginationBaseService { return url; } - getAll(): Observable { + getAll(additionalQueryParams?: { [name: string]: string }): Observable { if (!this.baseUrl) { return of(null); } @@ -168,6 +168,12 @@ export abstract class PaginationBaseService { let currentPage = 1; const listResultAll: T[] = []; const listResultAllSource = new Subject(); + let addFilter = ''; + if (additionalQueryParams) { + addFilter = Object.keys(additionalQueryParams) + .map((name) => `&${name}=${additionalQueryParams[name]}`) + .join(''); + } const getData = () => { if (!hasMore) { @@ -176,7 +182,7 @@ export abstract class PaginationBaseService { return; } - const url = this.buildUrlAll(currentPage++); + const url = this.buildUrlAll(currentPage++) + addFilter; this.http.get>(url).subscribe((c) => { if (c.page !== currentPage - 1) { hasMore = false; From 3f0232c3fe72fdf324fd1bd91ee5e195ea646136 Mon Sep 17 00:00:00 2001 From: ruslan-minukov Date: Wed, 3 Aug 2022 14:01:17 +0300 Subject: [PATCH 3/6] feat: added unit-test for getAll method with parameters --- .../src/lib/pagination-base.service.spec.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.spec.ts b/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.spec.ts index e203647..b96e9f6 100644 --- a/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.spec.ts +++ b/src/ng-lightquery/projects/ng-lightquery/src/lib/pagination-base.service.spec.ts @@ -224,6 +224,36 @@ describe('PaginationBaseService', () => { expect(returnedResult[1].id).toBe(2); })); + it('makes multiple requests when calling getAll with addition params', async(async () => { + let service = getService(); + service.baseUrl = '/users'; + await delay(1); + const getAllPromise = service.getAll({ userName: 'Alice' }).toPromise(); + + await delay(1); + let httpMock = getHttpMock(); + let req = httpMock.expectOne('/users?page=1&pageSize=500&userName=Alice'); + expect(req.request.method).toBe('GET'); + const response: PaginationResult = { + page: 1, + pageSize: 1, + totalCount: 1, + data: [{ id: 1, userName: 'Alice' }], + }; + req.flush(response); + + await delay(1); + req = httpMock.expectOne('/users?page=2&pageSize=500&userName=Alice'); + expect(req.request.method).toBe('GET'); + req.flush(response); + + const returnedResult = await getAllPromise; + expect(returnedResult.length).toBe(1); + + expect(returnedResult[0].id).toBe(1); + expect(returnedResult[0].userName).toBe('Alice'); + })); + it('does not emit result on error response', async(async () => { let hasReceivedResponse = false; let service = getService(); From d6641becf078c3e4afd0cce346924f199fd48edb Mon Sep 17 00:00:00 2001 From: Georg Dangl Date: Wed, 3 Aug 2022 15:43:24 +0200 Subject: [PATCH 4/6] Update build dependencies --- build/.build.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/.build.csproj b/build/.build.csproj index baa597e..528a4a5 100644 --- a/build/.build.csproj +++ b/build/.build.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 false False @@ -12,11 +12,11 @@ - - + + - + build all runtime; native; contentfiles; analyzers From f533815f74d00e300c0450dfcded1b7486f60d95 Mon Sep 17 00:00:00 2001 From: Georg Dangl Date: Wed, 3 Aug 2022 15:45:34 +0200 Subject: [PATCH 5/6] Disable node reuse for .NET tasks --- build/Build.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/Build.cs b/build/Build.cs index e72a86b..64bee1b 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -124,6 +124,7 @@ void SendTeamsMessage(string title, string message, bool isError) DotNetBuild(x => x .SetConfiguration(Configuration) .EnableNoRestore() + .SetProcessArgumentConfigurator(a => a.Add("-nodereuse:false")) .SetFileVersion(GitVersion.AssemblySemFileVer) .SetAssemblyVersion($"{GitVersion.Major}.{GitVersion.Minor}.{GitVersion.Patch}.0") .SetInformationalVersion(GitVersion.InformationalVersion)); @@ -173,6 +174,7 @@ void SendTeamsMessage(string title, string message, bool isError) .SetLoggers($"xunit;LogFilePath={OutputDirectory / projectName}_testresults-{targetFramework}.xml") .SetCoverletOutput($"{OutputDirectory / projectName}_coverage.xml") .SetProcessArgumentConfigurator(a => a + .Add("-nodereuse:false") .Add($"/p:Include=[LightQuery*]*") .Add($"/p:Exclude=[*Test*]*") .Add($"/p:ExcludeByAttribute=\\\"Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute\\\"") From 66bfc8eb757ec879baeacf7ddea3aec817620bf3 Mon Sep 17 00:00:00 2001 From: Georg Dangl Date: Wed, 3 Aug 2022 16:29:10 +0200 Subject: [PATCH 6/6] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a4e8ff..4ec860f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to **LightQuery** are documented here. +## v2.2.1: +- Added an optional parameter to the LightQuery client for Angular to supply custom query parameters when calling `getAll()` + ## v2.2.0: - Added a dedicated target for .NET 6 for the Entity Framework Core projects - Added tests for .NET 6