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:
parent
0330358139
commit
1020d6283d
@ -11,11 +11,13 @@ import {
|
|||||||
FilesGroupTable,
|
FilesGroupTable,
|
||||||
FilesTable,
|
FilesTable,
|
||||||
FilesTypeForMachine,
|
FilesTypeForMachine,
|
||||||
FilesTypesTable, IFileTable, IWithCount,
|
FilesTypesTable,
|
||||||
MachinesTable
|
IFileTable,
|
||||||
} from 'apps/backend/src/app/db/schema';
|
IWithCount,
|
||||||
|
MachinesTable,
|
||||||
|
} from "apps/backend/src/app/db/schema";
|
||||||
import { StorageService } from "apps/backend/src/app/storage/storage.service";
|
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()
|
@Injectable()
|
||||||
export class FilesService {
|
export class FilesService {
|
||||||
@ -131,13 +133,19 @@ export class FilesService {
|
|||||||
* @param {string} searchField - The value to search for within the file names.
|
* @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.
|
* @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 {
|
try {
|
||||||
const countResult = await this.database.use()
|
const countResult = await this.database
|
||||||
|
.use()
|
||||||
.select({ count: count() })
|
.select({ count: count() })
|
||||||
.from(FilesTable).where(ilike(FilesTable.fileName, String(`%${searchField}%`)))
|
.from(FilesTable)
|
||||||
|
.where(ilike(FilesTable.fileName, String(`%${searchField}%`)))
|
||||||
.prepare("searchFilesCount")
|
.prepare("searchFilesCount")
|
||||||
.execute()
|
.execute();
|
||||||
const dataResult = await this.database
|
const dataResult = await this.database
|
||||||
.use()
|
.use()
|
||||||
.select()
|
.select()
|
||||||
@ -151,8 +159,8 @@ export class FilesService {
|
|||||||
count: countResult[0].count,
|
count: countResult[0].count,
|
||||||
limit: limit,
|
limit: limit,
|
||||||
currentOffset: offset,
|
currentOffset: offset,
|
||||||
data: dataResult
|
data: dataResult,
|
||||||
}
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new InternalServerErrorException(error);
|
throw new InternalServerErrorException(error);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user