diff --git a/backend/src/apis/KlicktippController.ts b/backend/src/apis/KlicktippController.ts index 1df6bc7ab..a705e70e0 100644 --- a/backend/src/apis/KlicktippController.ts +++ b/backend/src/apis/KlicktippController.ts @@ -97,7 +97,9 @@ export const addFieldsToSubscriber = async ( newemail = '', newsmsnumber = '', ) => { + // eslint-disable-next-line no-console console.log('email', email) + // eslint-disable-next-line no-console console.log('fields', fields) if (!CONFIG.KLICKTIPP) return true const isLogin = await loginKlicktippUser() diff --git a/backend/src/graphql/resolver/util/eventList.ts b/backend/src/graphql/resolver/util/eventList.ts index 856d327eb..45afe1832 100644 --- a/backend/src/graphql/resolver/util/eventList.ts +++ b/backend/src/graphql/resolver/util/eventList.ts @@ -2,9 +2,10 @@ import { Event as DbEvent } from '@entity/Event' import { User } from '@entity/User' import { UserContact } from '@entity/UserContact' -export const lastDateTimeEvents = async (eventType: string): Promise => { - return DbEvent - .createQueryBuilder('event') +export const lastDateTimeEvents = async ( + eventType: string, +): Promise<{ email: string; value: Date }[]> => { + return DbEvent.createQueryBuilder('event') .select('MAX(event.created_at)', 'value') .leftJoin(User, 'user', 'affected_user_id = user.id') .leftJoin(UserContact, 'usercontact', 'user.id = usercontact.user_id') @@ -13,4 +14,4 @@ export const lastDateTimeEvents = async (eventType: string): Promise .andWhere('usercontact.email IS NOT NULL') .groupBy('event.affected_user_id') .getRawMany() -} \ No newline at end of file +} diff --git a/backend/src/util/klicktipp.ts b/backend/src/util/klicktipp.ts index 4ee5455a8..762dac961 100644 --- a/backend/src/util/klicktipp.ts +++ b/backend/src/util/klicktipp.ts @@ -1,12 +1,11 @@ - // eslint-disable @typescript-eslint/no-explicit-any +// eslint-disable @typescript-eslint/no-explicit-any import { User } from '@entity/User' import { getKlickTippUser, addFieldsToSubscriber } from '@/apis/KlicktippController' +import { EventType } from '@/event/EventType' +import { lastDateTimeEvents } from '@/graphql/resolver/util/eventList' import LogError from '@/server/LogError' import connection from '@/typeorm/connection' -import { lastDateTimeEvents } from '@/graphql/resolver/util/eventList' -import { EventType } from '@/event/EventType' -import { Event as DbEvent } from '@/event/Event' export async function retrieveNotRegisteredEmails(): Promise { const con = await connection() @@ -31,9 +30,12 @@ export async function retrieveNotRegisteredEmails(): Promise { return notRegisteredUser } -function klickTippSendFieldToUser(events: any, value: string): void { - for(const event of events) { - addFieldsToSubscriber(event.email, { [value]: event.value }) +async function klickTippSendFieldToUser( + events: { email: string; value: Date }[], + value: string, +): Promise { + for (const event of events) { + await addFieldsToSubscriber(event.email, { [value]: event.value }) } } @@ -44,22 +46,22 @@ export async function exportEventDataToKlickTipp(): Promise { } const lastLoginEvents = await lastDateTimeEvents(EventType.USER_LOGIN) - klickTippSendFieldToUser(lastLoginEvents, 'GDD last login') + void klickTippSendFieldToUser(lastLoginEvents, 'GDD last login') const registeredEvents = await lastDateTimeEvents(EventType.USER_ACTIVATE_ACCOUNT) - klickTippSendFieldToUser(registeredEvents, 'GDD date of registration') + void klickTippSendFieldToUser(registeredEvents, 'GDD date of registration') const receiveTransactionEvents = await lastDateTimeEvents(EventType.TRANSACTION_RECEIVE) - klickTippSendFieldToUser(receiveTransactionEvents, 'GDD last received') - + void klickTippSendFieldToUser(receiveTransactionEvents, 'GDD last received') + const contributionCreateEvents = await lastDateTimeEvents(EventType.TRANSACTION_SEND) - klickTippSendFieldToUser(contributionCreateEvents, 'GDD last sent') - + void klickTippSendFieldToUser(contributionCreateEvents, 'GDD last sent') + const linkRedeemedEvents = await lastDateTimeEvents(EventType.TRANSACTION_LINK_REDEEM) - klickTippSendFieldToUser(linkRedeemedEvents, 'GDD last invited') - + void klickTippSendFieldToUser(linkRedeemedEvents, 'GDD last invited') + const confirmContributionEvents = await lastDateTimeEvents(EventType.ADMIN_CONTRIBUTION_CONFIRM) - klickTippSendFieldToUser(confirmContributionEvents, 'GDD last created') + void klickTippSendFieldToUser(confirmContributionEvents, 'GDD last created') } void exportEventDataToKlickTipp() // void retrieveNotRegisteredEmails()