patches v1.3.7 #79

Merged
jkeffects merged 2 commits from develop into main 2025-03-24 08:21:21 +00:00
11 changed files with 43 additions and 32 deletions

View file

@ -1,7 +1,7 @@
export interface SynchronizeProtocolAgendaCommand { export interface SynchronizeProtocolAgendaCommand {
id?: number; id: number;
topic: string; topic: string;
context: string; context: string;
sort?: number; sort: number;
protocolId: number; protocolId: number;
} }

View file

@ -39,13 +39,16 @@ export default abstract class ProtocolAgendaCommandHandler {
*/ */
static async sync(syncProtocolAgenda: Array<SynchronizeProtocolAgendaCommand>): Promise<void> { static async sync(syncProtocolAgenda: Array<SynchronizeProtocolAgendaCommand>): Promise<void> {
return await dataSource return await dataSource
.createQueryBuilder() .transaction(async (transactionalEntityManager) => {
.insert() for (const agenda of syncProtocolAgenda) {
.into(protocolAgenda) await transactionalEntityManager
.values(syncProtocolAgenda) .createQueryBuilder()
.orUpdate(["topic", "context", "sort"], ["id"]) .update(protocolAgenda)
.execute() .set(agenda)
.then(() => {}) .where({ id: agenda.id })
.execute();
}
})
.catch((err) => { .catch((err) => {
throw new DatabaseActionException("SYNC", "protocolAgenda", err); throw new DatabaseActionException("SYNC", "protocolAgenda", err);
}); });

View file

@ -1,7 +1,7 @@
export interface SynchronizeProtocolDecisionCommand { export interface SynchronizeProtocolDecisionCommand {
id?: number; id: number;
topic: string; topic: string;
context: string; context: string;
sort?: number; sort: number;
protocolId: number; protocolId: number;
} }

View file

@ -38,12 +38,16 @@ export default abstract class ProtocolDecisionCommandHandler {
*/ */
static async sync(syncProtocolDecisions: Array<SynchronizeProtocolDecisionCommand>): Promise<void> { static async sync(syncProtocolDecisions: Array<SynchronizeProtocolDecisionCommand>): Promise<void> {
return await dataSource return await dataSource
.createQueryBuilder() .transaction(async (transactionalEntityManager) => {
.insert() for (const decision of syncProtocolDecisions) {
.into(protocolDecision) await transactionalEntityManager
.values(syncProtocolDecisions) .createQueryBuilder()
.orUpdate(["topic", "context", "sort"], ["id"]) .update(protocolDecision)
.execute() .set(decision)
.where({ id: decision.id })
.execute();
}
})
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new DatabaseActionException("SYNC", "protocolDecision", err); throw new DatabaseActionException("SYNC", "protocolDecision", err);

View file

@ -5,6 +5,6 @@ export interface SynchronizeProtocolVotingCommand {
favour: number; favour: number;
abstain: number; abstain: number;
against: number; against: number;
sort?: number; sort: number;
protocolId: number; protocolId: number;
} }

View file

@ -38,12 +38,16 @@ export default abstract class ProtocolVotingCommandHandler {
*/ */
static async sync(syncProtocolVotings: Array<SynchronizeProtocolVotingCommand>): Promise<void> { static async sync(syncProtocolVotings: Array<SynchronizeProtocolVotingCommand>): Promise<void> {
return await dataSource return await dataSource
.createQueryBuilder() .transaction(async (transactionalEntityManager) => {
.insert() for (const voting of syncProtocolVotings) {
.into(protocolVoting) await transactionalEntityManager
.values(syncProtocolVotings) .createQueryBuilder()
.orUpdate(["topic", "context", "favour", "abstain", "against", "sort"], ["id"]) .update(protocolVoting)
.execute() .set(voting)
.where({ id: voting.id })
.execute();
}
})
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new DatabaseActionException("SYNC", "protocolVoting", err); throw new DatabaseActionException("SYNC", "protocolVoting", err);

View file

@ -19,7 +19,7 @@ export default abstract class NewsletterConfigCommandHandler {
comTypeId: setNewsletterConfig.comTypeId, comTypeId: setNewsletterConfig.comTypeId,
config: setNewsletterConfig.config, config: setNewsletterConfig.config,
}) })
.orUpdate(["config"], "comTypeId") .orUpdate(["config"], ["comTypeId"])
.execute() .execute()
.then((result) => {}) .then((result) => {})
.catch((err) => { .catch((err) => {

View file

@ -317,7 +317,7 @@ export async function synchronizeProtocolAgendaById(req: Request, res: Response)
let syncAgenda: Array<SynchronizeProtocolAgendaCommand> = agenda.map( let syncAgenda: Array<SynchronizeProtocolAgendaCommand> = agenda.map(
(a: ProtocolAgendaViewModel): SynchronizeProtocolAgendaCommand => ({ (a: ProtocolAgendaViewModel): SynchronizeProtocolAgendaCommand => ({
id: a.id ?? null, id: a.id,
topic: a.topic, topic: a.topic,
context: a.context, context: a.context,
sort: a.sort, sort: a.sort,
@ -341,7 +341,7 @@ export async function synchronizeProtocolDecisonsById(req: Request, res: Respons
let syncDecision: Array<SynchronizeProtocolDecisionCommand> = decisions.map( let syncDecision: Array<SynchronizeProtocolDecisionCommand> = decisions.map(
(d: ProtocolDecisionViewModel): SynchronizeProtocolDecisionCommand => ({ (d: ProtocolDecisionViewModel): SynchronizeProtocolDecisionCommand => ({
id: d.id ?? null, id: d.id,
topic: d.topic, topic: d.topic,
context: d.context, context: d.context,
sort: d.sort, sort: d.sort,
@ -365,7 +365,7 @@ export async function synchronizeProtocolVotingsById(req: Request, res: Response
let syncVoting: Array<SynchronizeProtocolVotingCommand> = votings.map( let syncVoting: Array<SynchronizeProtocolVotingCommand> = votings.map(
(v: ProtocolVotingViewModel): SynchronizeProtocolVotingCommand => ({ (v: ProtocolVotingViewModel): SynchronizeProtocolVotingCommand => ({
id: v.id ?? null, id: v.id,
topic: v.topic, topic: v.topic,
context: v.context, context: v.context,
favour: v.favour, favour: v.favour,

View file

@ -748,7 +748,7 @@ export default abstract class BackupHelper {
.insert() .insert()
.into("template_usage") .into("template_usage")
.values(data?.["template_usage"] ?? []) .values(data?.["template_usage"] ?? [])
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"]) .orIgnore()
.execute(); .execute();
} }
private static async setUser(data: { [key: string]: Array<any> }): Promise<void> { private static async setUser(data: { [key: string]: Array<any> }): Promise<void> {

View file

@ -106,7 +106,7 @@ export class CreateSchema1738166167472 implements MigrationInterface {
.insert() .insert()
.into(templateUsage) .into(templateUsage)
.values([{ scope: "newsletter" }, { scope: "protocol" }, { scope: "member.list" }]) .values([{ scope: "newsletter" }, { scope: "protocol" }, { scope: "member.list" }])
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"]) .orIgnore()
.execute(); .execute();
await queryRunner.createTable(protocol_table, true, true, true); await queryRunner.createTable(protocol_table, true, true, true);

View file

@ -11,7 +11,7 @@ export class TemplatesAndProtocolSort1742549956787 implements MigrationInterface
.insert() .insert()
.into(templateUsage) .into(templateUsage)
.values([{ scope: "member" }]) .values([{ scope: "member" }])
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"]) .orIgnore()
.execute(); .execute();
await queryRunner.manager await queryRunner.manager
@ -47,7 +47,7 @@ export class TemplatesAndProtocolSort1742549956787 implements MigrationInterface
.insert() .insert()
.into(templateUsage) .into(templateUsage)
.values([{ scope: "member.list" }]) .values([{ scope: "member.list" }])
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"]) .orIgnore()
.execute(); .execute();
await queryRunner.manager.createQueryBuilder().delete().from(templateUsage).where({ scope: "member" }).execute(); await queryRunner.manager.createQueryBuilder().delete().from(templateUsage).where({ scope: "member" }).execute();