mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 06:16:18 +00:00
importer: idcomercio
This commit is contained in:
parent
1f9daaa016
commit
ddb202dc93
1 changed files with 2 additions and 1 deletions
|
@ -61,6 +61,7 @@ async function importSucursales(
|
|||
async function importDataset(dir: string) {
|
||||
console.log(dir);
|
||||
const date = basename(dir).match(/(\d{4}-\d{2}-\d{2})/)![1];
|
||||
const id_comercio = basename(dir).match(/comercio-sepa-(\d+)/)![1];
|
||||
// TODO: parsear "Ultima actualizacion" al final del CSV y insertarlo en la tabla datasets
|
||||
|
||||
// {
|
||||
|
@ -73,7 +74,7 @@ async function importDataset(dir: string) {
|
|||
await sql.begin(async (sql) => {
|
||||
let datasetId: number;
|
||||
const res =
|
||||
await sql`insert into datasets (name, date) values (${basename(dir)}, ${date}) returning id`;
|
||||
await sql`insert into datasets (name, date, id_comercio) values (${basename(dir)}, ${date}, ${id_comercio}) returning id`;
|
||||
datasetId = res[0].id;
|
||||
|
||||
const comercios: Papa.ParseResult<{ comercio_cuit: string }> = Papa.parse(
|
||||
|
|
Loading…
Reference in a new issue