obtener carpetas, carpetas duplicadas y alumnos sin carpeta de la db
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
duplicados()
|
||||
getAlumnosNull()
|
||||
|
||||
@@ -151,4 +151,5 @@ const borrarTodo = () => {
|
||||
module.exports = {
|
||||
folder,
|
||||
uploadFile,
|
||||
list
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user