Fix linting rules

This commit is contained in:
elweyn 2023-04-04 19:38:17 +02:00
parent f486bc0fd0
commit d09aa6c43d
3 changed files with 25 additions and 20 deletions

View File

@ -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()

View File

@ -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<DbEvent[]> => {
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<DbEvent[]>
.andWhere('usercontact.email IS NOT NULL')
.groupBy('event.affected_user_id')
.getRawMany()
}
}

View File

@ -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<string[]> {
const con = await connection()
@ -31,9 +30,12 @@ export async function retrieveNotRegisteredEmails(): Promise<string[]> {
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<void> {
for (const event of events) {
await addFieldsToSubscriber(event.email, { [value]: event.value })
}
}
@ -44,22 +46,22 @@ export async function exportEventDataToKlickTipp(): Promise<void> {
}
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()