async insertELOEntities(entities){
try{
//const xata = getXataClient();
const sql = neon(process.env.DATABASE_URL_TEST);
const db = drizzle({ client: sql });
const eloEntities = entities.map(entity => ({
entity_cagematch_id: entity.id,
type_id: getEntityTypeByDescription(entity.type).id,
entity_name: entity.name,
elo_date: entity.lastMatchDate,
elo_prev_elo: entity.oldElo,
elo_new_elo: entity.newELO
}));
const inserted = await db.insert(vEntityEloView).values(eloEntities).execute();
if(inserted.rowCount > 0){
return inserted.rowCount;
}
return inserted;
} catch(e){
logger.error({message: e.message, stack: e.stack});
}
return null;
}
async insertELOEntities(entities){
try{
//const xata = getXataClient();
const sql = neon(process.env.DATABASE_URL_TEST);
const db = drizzle({ client: sql });
const eloEntities = entities.map(entity => ({
entity_cagematch_id: entity.id,
type_id: getEntityTypeByDescription(entity.type).id,
entity_name: entity.name,
elo_date: entity.lastMatchDate,
elo_prev_elo: entity.oldElo,
elo_new_elo: entity.newELO
}));
const inserted = await db.insert(vEntityEloView).values(eloEntities).execute();
if(inserted.rowCount > 0){
return inserted.rowCount;
}
return inserted;
} catch(e){
logger.error({message: e.message, stack: e.stack});
}
return null;
}