From 1020d6283db785463a4834dc13c1084f45825798 Mon Sep 17 00:00:00 2001 From: Mathis Date: Thu, 17 Oct 2024 12:26:51 +0200 Subject: [PATCH] Refactor code to improve readability and consistency Reformatted import statements and function parameters for better readability. Improved alignment and punctuation to enhance code consistency and maintainability. --- apps/backend/src/app/files/files.service.ts | 30 +++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/backend/src/app/files/files.service.ts b/apps/backend/src/app/files/files.service.ts index 18d2242..a895ae9 100644 --- a/apps/backend/src/app/files/files.service.ts +++ b/apps/backend/src/app/files/files.service.ts @@ -11,11 +11,13 @@ import { FilesGroupTable, FilesTable, FilesTypeForMachine, - FilesTypesTable, IFileTable, IWithCount, - MachinesTable -} from 'apps/backend/src/app/db/schema'; + FilesTypesTable, + IFileTable, + IWithCount, + MachinesTable, +} from "apps/backend/src/app/db/schema"; import { StorageService } from "apps/backend/src/app/storage/storage.service"; -import { count, eq, ilike } from 'drizzle-orm'; +import { count, eq, ilike } from "drizzle-orm"; @Injectable() export class FilesService { @@ -131,13 +133,19 @@ export class FilesService { * @param {string} searchField - The value to search for within the file names. * @return {Promise>} A promise that resolves to an object containing the count of files that match the search criteria, the provided limit, the current offset, and the matching data. */ - public async search(limit: number, offset: number, searchField: string): Promise> { + public async search( + limit: number, + offset: number, + searchField: string, + ): Promise> { try { - const countResult = await this.database.use() - .select({count : count()}) - .from(FilesTable).where(ilike(FilesTable.fileName, String(`%${searchField}%`))) + const countResult = await this.database + .use() + .select({ count: count() }) + .from(FilesTable) + .where(ilike(FilesTable.fileName, String(`%${searchField}%`))) .prepare("searchFilesCount") - .execute() + .execute(); const dataResult = await this.database .use() .select() @@ -151,8 +159,8 @@ export class FilesService { count: countResult[0].count, limit: limit, currentOffset: offset, - data: dataResult - } + data: dataResult, + }; } catch (error) { throw new InternalServerErrorException(error); }