From a5b49b286da67a8ff08558075a4519cc68eb7a6e Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 1 Mar 2023 20:52:12 +0100 Subject: [PATCH] Feature/filter item activities from search results (#1759) * Filter ITEM activities from search results * Update changelog --- CHANGELOG.md | 1 + .../src/services/data-provider/manual/manual.service.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e84764758..125b2bbe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Filtered activities with type `ITEM` from search results - Considered the user's language in the _Stripe_ checkout - Upgraded the _Stripe_ dependencies - Upgraded `twitter-api-v2` from version `1.10.3` to `1.14.2` diff --git a/apps/api/src/services/data-provider/manual/manual.service.ts b/apps/api/src/services/data-provider/manual/manual.service.ts index 9f9502968..876910f96 100644 --- a/apps/api/src/services/data-provider/manual/manual.service.ts +++ b/apps/api/src/services/data-provider/manual/manual.service.ts @@ -16,6 +16,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { DataSource, SymbolProfile } from '@prisma/client'; import bent from 'bent'; import * as cheerio from 'cheerio'; +import { isUUID } from 'class-validator'; import { addDays, format, isBefore } from 'date-fns'; @Injectable() @@ -162,7 +163,7 @@ export class ManualService implements DataProviderInterface { } public async search(aQuery: string): Promise<{ items: LookupItem[] }> { - const items = await this.prismaService.symbolProfile.findMany({ + let items = await this.prismaService.symbolProfile.findMany({ select: { currency: true, dataSource: true, @@ -189,6 +190,11 @@ export class ManualService implements DataProviderInterface { } }); + items = items.filter(({ symbol }) => { + // Remove UUID symbols (activities of type ITEM) + return !isUUID(symbol); + }); + return { items }; } }