Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 1x 1x 1x 1x 1x 18x | import {inject} from '@loopback/core';
import {LogChainDataSource} from '../datasources';
import {FlowDefaultGroup, FlowDefaultGroupRelations} from '../models';
import {BaseCrudRepository} from './base-crud.repository.base';
export class FlowDefaultGroupRepository extends BaseCrudRepository<
FlowDefaultGroup,
typeof FlowDefaultGroup.prototype.id,
FlowDefaultGroupRelations
> {
constructor(@inject('datasources.logchain') dataSource: LogChainDataSource) {
super(FlowDefaultGroup, dataSource);
}
/**
* Find group by journey id.
* @param flow_id The flow id.
* @param step_id The step id.
*/
async findGroupsByJourneyId(
flow_id: number,
step_id: number,
): Promise<FlowDefaultGroup[]> {
const groups = await this.execute(
`SELECT
fdg.* ,
STRING_AGG (fdp.name, ', ') company_personas
FROM
flows_default_group as fdg
INNER JOIN flows_default_persona as fdp ON fdp.id =ANY(fdg.flow_personas)
WHERE
$1=ANY( fdg.journey_points )
AND fdg.flow_default_id=$2
GROUP BY fdg.id
ORDER BY fdg."order";`,
[step_id, flow_id],
);
return groups as FlowDefaultGroup[];
}
/**
* Find group by flow id.
* @param flow_id The flow id.
*/
async findGroupsByFlowId(flow_id: number): Promise<FlowDefaultGroup[]> {
const groups = await this.execute(
`SELECT
fdg.* ,
json_agg(json_build_object('id', fdp.id, 'name', fdp.name)) as company_personas
FROM
flows_default_group as fdg
INNER JOIN flows_default_persona as fdp ON fdp.id =ANY(fdg.flow_personas)
WHERE
fdg.flow_default_id=$1
GROUP BY fdg.id
ORDER BY fdg."order";`,
[flow_id],
);
return groups as FlowDefaultGroup[];
}
}
|