mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
get things working, hurray
This commit is contained in:
parent
9959a69693
commit
b2a5f09df7
@ -15,7 +15,7 @@
|
||||
"lint": "eslint --max-warnings=0 .",
|
||||
"test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles",
|
||||
"seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts",
|
||||
"klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts",
|
||||
"klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/executeKlicktipp.ts",
|
||||
"locales": "scripts/sort.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
16
backend/src/util/executeKlicktipp.ts
Normal file
16
backend/src/util/executeKlicktipp.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { getConnection } from '@/typeorm/connection'
|
||||
|
||||
import { exportEventDataToKlickTipp } from './klicktipp'
|
||||
|
||||
async function executeKlicktipp(): Promise<boolean> {
|
||||
const connection = await getConnection()
|
||||
if (connection) {
|
||||
await exportEventDataToKlickTipp()
|
||||
await connection.close()
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
void executeKlicktipp()
|
||||
@ -4,6 +4,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import { Connection } from '@dbTools/typeorm'
|
||||
import { Event as DbEvent } from '@entity/Event'
|
||||
import { User as DbUser } from '@entity/User'
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
|
||||
import { testEnvironment, cleanDB, resetToken } from '@test/helpers'
|
||||
@ -15,10 +16,10 @@ import { userFactory } from '@/seeds/factory/user'
|
||||
import { login } from '@/seeds/graphql/mutations'
|
||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||
import { connection } from '@/typeorm/connection'
|
||||
|
||||
import { exportEventDataToKlickTipp } from './klicktipp'
|
||||
|
||||
/*
|
||||
jest.mock('@/apis/KlicktippController', () => {
|
||||
const originalModule = jest.requireActual('@/apis/KlicktippController')
|
||||
return {
|
||||
@ -28,6 +29,9 @@ jest.mock('@/apis/KlicktippController', () => {
|
||||
addFieldsToSubscriber: jest.fn((email, a) => originalModule.addFieldsToSubscriber(email, a)),
|
||||
}
|
||||
})
|
||||
*/
|
||||
|
||||
jest.mock('@/apis/KlicktippController')
|
||||
|
||||
// jest.mock('@/typeorm/connection', () => {
|
||||
// const originalModule = jest.requireActual('@/typeorm/connection')
|
||||
@ -71,8 +75,7 @@ describe('klicktipp', () => {
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
await con.close()
|
||||
void exportEventDataToKlickTipp()
|
||||
// await con.close()
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
@ -80,7 +83,10 @@ describe('klicktipp', () => {
|
||||
})
|
||||
|
||||
describe('exportEventDataToKlickTipp', () => {
|
||||
it('calls the KlicktippController', () => {
|
||||
it('calls the KlicktippController', async () => {
|
||||
// console.log(await lastDateTimeEvents('USER_LOGIN'))
|
||||
// console.log(con)
|
||||
await exportEventDataToKlickTipp()
|
||||
expect(addFieldsToSubscriber).toBeCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
// eslint-disable @typescript-eslint/no-explicit-any
|
||||
import { Connection } from '@dbTools/typeorm'
|
||||
import { Event as DbEvent } from '@entity/Event'
|
||||
import { User } from '@entity/User'
|
||||
import { UserContact } from '@entity/UserContact'
|
||||
|
||||
import { getKlickTippUser, addFieldsToSubscriber } from '@/apis/KlicktippController'
|
||||
import { EventType } from '@/event/EventType'
|
||||
@ -9,10 +11,6 @@ import { LogError } from '@/server/LogError'
|
||||
import { getConnection } from '@/typeorm/connection'
|
||||
|
||||
export async function retrieveNotRegisteredEmails(): Promise<string[]> {
|
||||
const con = await getConnection()
|
||||
if (!con) {
|
||||
throw new LogError('No connection to database')
|
||||
}
|
||||
const users = await User.find({ relations: ['emailContact'] })
|
||||
const notRegisteredUser = []
|
||||
for (const user of users) {
|
||||
@ -24,7 +22,6 @@ export async function retrieveNotRegisteredEmails(): Promise<string[]> {
|
||||
console.log(`${user.emailContact.email}`)
|
||||
}
|
||||
}
|
||||
await con.close()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('User die nicht bei KlickTipp vorhanden sind: ', notRegisteredUser)
|
||||
return notRegisteredUser
|
||||
@ -40,16 +37,7 @@ async function klickTippSendFieldToUser(
|
||||
}
|
||||
}
|
||||
|
||||
function getMyConnection(): Promise<Connection | null> {
|
||||
return connection()
|
||||
}
|
||||
|
||||
export async function exportEventDataToKlickTipp(): Promise<void> {
|
||||
const connectionInstance = await getConnection()
|
||||
if (!connectionInstance) {
|
||||
throw new LogError('No connection to database')
|
||||
}
|
||||
|
||||
export async function exportEventDataToKlickTipp(): Promise<boolean> {
|
||||
const lastLoginEvents = await lastDateTimeEvents(EventType.USER_LOGIN)
|
||||
await klickTippSendFieldToUser(lastLoginEvents, 'field186060')
|
||||
|
||||
@ -68,7 +56,8 @@ export async function exportEventDataToKlickTipp(): Promise<void> {
|
||||
const confirmContributionEvents = await lastDateTimeEvents(EventType.ADMIN_CONTRIBUTION_CONFIRM)
|
||||
await klickTippSendFieldToUser(confirmContributionEvents, 'field185675')
|
||||
|
||||
await connectionInstance.close()
|
||||
return true
|
||||
}
|
||||
void exportEventDataToKlickTipp()
|
||||
|
||||
// void exportEventDataToKlickTipp()
|
||||
// void retrieveNotRegisteredEmails()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user