From 49de7366f44d47ac3c2e4449454f3aad6b4db14f Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 16 Aug 2022 07:02:07 +0200 Subject: [PATCH] Add method to log every user that is not registered at KlickTipp. --- backend/src/klicktipp.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 backend/src/klicktipp.ts diff --git a/backend/src/klicktipp.ts b/backend/src/klicktipp.ts new file mode 100644 index 000000000..3139cd296 --- /dev/null +++ b/backend/src/klicktipp.ts @@ -0,0 +1,28 @@ +import connection from '@/typeorm/connection' +import { getKlickTippUser } from './apis/KlicktippController' +import { User } from '../../database/entity/User' +import { getConnection } from '@dbTools/typeorm' + +export async function retrieveNotRegisteredEmails(): Promise { + const con = await connection() + if (!con) { + throw new Error('No connection to database') + } + const users = await User.find() + const notRegisteredUser = [] + for (let i = 0; i < users.length; i++) { + const user = users[i] + try { + await getKlickTippUser(user.email) + } catch (err) { + notRegisteredUser.push(user.email) + // eslint-disable-next-line no-console + console.log(`${user.email}`) + } + } + await con.close() + console.log('User die nicht bei KlickTipp vorhanden sind: ', notRegisteredUser) + return notRegisteredUser +} + +retrieveNotRegisteredEmails()