Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 11879e8626 | |||
| 16df3a5d66 | |||
| bc6807c210 | |||
| aa4c50bc7c |
Generated
+6
-6
@@ -205,9 +205,9 @@
|
||||
"integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.21.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
|
||||
"integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
|
||||
"version": "0.21.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
|
||||
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.10.0"
|
||||
}
|
||||
@@ -828,9 +828,9 @@
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
|
||||
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz",
|
||||
"integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg=="
|
||||
},
|
||||
"forwarded": {
|
||||
"version": "0.1.2",
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
"author": "cidwa",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.0",
|
||||
"axios": "^0.21.1",
|
||||
"bcrypt": "^5.0.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"colors": "^1.4.0",
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
const drive = require("../helper/drive")
|
||||
const Servicio = require('../db/tablas/Servicio');
|
||||
const Usuario = require('../db/tablas/Usuario');
|
||||
|
||||
const getCarpetas = async () => {
|
||||
let listado = await drive.list()
|
||||
let carpetas = []
|
||||
let noBorrar = 'Babyhelon'
|
||||
|
||||
for (let i = 0; i < listado.length; i++) {
|
||||
if (listado[i].mimeType == 'application/vnd.google-apps.folder')
|
||||
carpetas.push(listado[i])
|
||||
}
|
||||
carpetas = carpetas.filter(item => item.name !== noBorrar)
|
||||
return carpetas
|
||||
}
|
||||
|
||||
const duplicados = () => {
|
||||
getCarpetas().then((carpetas) => {
|
||||
|
||||
const duplicados = []
|
||||
const tempArray = [...carpetas].sort();
|
||||
|
||||
for (let i = 0; i < tempArray.length - 1; i++) {
|
||||
if (tempArray[i + 1].name === tempArray[i].name) {
|
||||
duplicados.push(tempArray[i]);
|
||||
}
|
||||
else {
|
||||
if (i != 0 && tempArray[i - 1].name === tempArray[i].name) {
|
||||
duplicados.push(tempArray[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(duplicados)
|
||||
return duplicados
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const getAlumnosNull = async () => {
|
||||
return Servicio.findAll({
|
||||
where: { carpeta: null },
|
||||
include: [
|
||||
{ model: Usuario },
|
||||
],
|
||||
})
|
||||
.then((res) => {
|
||||
const alumnosNull = []
|
||||
console.log("servicios con carpeta null = " + res.length)
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
alumnosNull.push(res[i].Usuario.usuario)
|
||||
}
|
||||
return alumnosNull
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const insertIdCarpetas = async () => {
|
||||
getAlumnosNull()
|
||||
.then((alumnos) => {
|
||||
|
||||
getCarpetas()
|
||||
.then(async(carpetas) => {
|
||||
console.log(alumnos) // alumnos con carpeta null
|
||||
console.log(carpetas) // carpetas disponibles en drive (este array aun tiene carpetas repetidas)
|
||||
|
||||
for (let i = 0; i < alumnos.length; i++) {
|
||||
for (let j = 0; j < carpetas.length; j++) {
|
||||
if (alumnos[i] == carpetas[j].name) {
|
||||
console.log(alumnos[i]) // alumnos qno tienen carpeta pero si existe su carpeta
|
||||
await Servicio.update({
|
||||
carpeta: carpetas[j].id
|
||||
},
|
||||
{
|
||||
where: { idUsuario: alumnos[i] }
|
||||
}
|
||||
)
|
||||
.then((rep) => {
|
||||
console.log(rep)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//duplicados()
|
||||
//getAlumnosNull()
|
||||
insertIdCarpetas()
|
||||
|
||||
@@ -151,4 +151,5 @@ const borrarTodo = () => {
|
||||
module.exports = {
|
||||
folder,
|
||||
uploadFile,
|
||||
list
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user