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.
This commit is contained in:
2024-10-17 12:26:51 +02:00
parent 0330358139
commit 1020d6283d

View File

@@ -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<IWithCount<IFileTable>>} 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<IWithCount<IFileTable>> {
public async search(
limit: number,
offset: number,
searchField: string,
): Promise<IWithCount<IFileTable>> {
try {
const countResult = await this.database.use()
const countResult = await this.database
.use()
.select({ count: count() })
.from(FilesTable).where(ilike(FilesTable.fileName, String(`%${searchField}%`)))
.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);
}