mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
start using query builder instead of options, because it cannot help us here
This commit is contained in:
parent
3e8f533789
commit
e00719714e
@ -3,6 +3,9 @@ import { Contribution as DbContribution } from '@entity/Contribution'
|
||||
|
||||
import { Paginated } from '@arg/Paginated'
|
||||
import { SearchContributionsFilterArgs } from '@arg/SearchContributionsFilterArgs'
|
||||
import { Connection } from '@typeorm/connection'
|
||||
|
||||
import { LogError } from '@/server/LogError'
|
||||
|
||||
interface Relations {
|
||||
[key: string]: boolean | Relations
|
||||
@ -14,11 +17,20 @@ export const findContributions = async (
|
||||
withDeleted = false,
|
||||
relations: Relations | undefined = undefined,
|
||||
): Promise<[DbContribution[], number]> => {
|
||||
const connection = await Connection.getInstance()
|
||||
if (!connection) {
|
||||
throw new LogError('Cannot connect to db')
|
||||
}
|
||||
const requiredWhere = {
|
||||
...(filter.statusFilter?.length && { contributionStatus: In(filter.statusFilter) }),
|
||||
...(filter.userId && { userId: filter.userId }),
|
||||
...(filter.noHashtag && { memo: Not(Like(`%#%`)) }),
|
||||
}
|
||||
const queryBuilder = connection.getRepository(DbContribution).createQueryBuilder('Contribution')
|
||||
queryBuilder.where(requiredWhere)
|
||||
return queryBuilder.getManyAndCount()
|
||||
/*
|
||||
|
||||
|
||||
let where =
|
||||
filter.query && relations?.user
|
||||
@ -65,4 +77,5 @@ export const findContributions = async (
|
||||
skip: (paginate.currentPage - 1) * paginate.pageSize,
|
||||
take: paginate.pageSize,
|
||||
})
|
||||
*/
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
"@model/*": ["src/graphql/model/*"],
|
||||
"@union/*": ["src/graphql/union/*"],
|
||||
"@repository/*": ["src/typeorm/repository/*"],
|
||||
"@typeorm/*": ["src/typeorm/*"],
|
||||
"@test/*": ["test/*"],
|
||||
/* external */
|
||||
"@dbTools/*": ["../database/src/*", "../../database/build/src/*"],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user