Explorar el Código

Merge branch 'master' of http://git.fmode.cn:3000/bin/edu-textbook

warrior hace 3 semanas
padre
commit
23d19933a7
Se han modificado 1 ficheros con 20 adiciones y 8 borrados
  1. 20 8
      server/cloud/tbook/test/test-export.js

+ 20 - 8
server/cloud/tbook/test/test-export.js

@@ -63,7 +63,7 @@ async function main(){
         // console.log(await exportProcessReportDocs(null,["KvvN9lWhri"]))
         // console.log(await exportProcessReportDocs(null,["zVVwoy6ETT"],true))
         // console.log(await exportProcessReportDocs(null,["7PAU2PNcoB"],true))
-        console.log(await exportProcessReportDocs(null,["v8DjfCGfrP"],true))
+        // console.log(await exportProcessReportDocs(null,["v8DjfCGfrP"],true))
         // console.log(await exportProcessReportDocs(null,["7sDvlq2w6Z"],true))
         
         // console.log(await exportProcessReportDocs(null,["Oa1yB6n64u","j4pt2MMTXM","jAMGxwrl1F","BwZpEoOtS8","X10kCktA0r"]))
@@ -76,6 +76,7 @@ async function main(){
 
         // 根据export.txt 导出全部
         // await exportAllFromTxt()
+        exportAll400();
 
     }catch(err){
         console.error(err)
@@ -96,9 +97,24 @@ main()
 //     merge: true
 //   });
 
-async function exportAllFromTxt(){
-    let txt = fs.readFileSync(path.join(__dirname,"../","export.txt")).toString();
-    let list = txt.split("\n");
+async function exportAll400(){
+    let query = new Parse.Query("EduTextbook");
+    query.select("objectId");
+    query.limit(20000);
+    query.notEqualTo("isDeleted",true);
+    query.notEqualTo("discard",true);
+    query.equalTo("render",true);
+    query.containedIn("status",['400']);
+    let list = await query.find();
+    list = list.map(item=>item?.id)
+    console.log(list.length)
+    exportAllFromTxt(list)
+}
+async function exportAllFromTxt(list){
+    if(!list?.length){
+        let txt = fs.readFileSync(path.join(__dirname,"../","export.txt")).toString();
+        list = txt.split("\n");
+    }
     list = list.filter(item=>{
         let tdir = path.join(__dirname,"../export",item);
         if(!fs.existsSync(tdir)){return true};
@@ -116,9 +132,6 @@ async function exportAllFromTxt(){
     for (let index = 0; index < list.length; index++) {
         let id = list[index];
         console.log(index+1,id)
-        console.log(index+1,id)
-        console.log(index+1,id)
-        console.log(index+1,id)
         let docDir = path.join(__dirname,"../export",id)
         console.log(docDir)
         if(!fs.existsSync(docDir)) {fs.mkdirSync(docDir)};
@@ -132,7 +145,6 @@ async function exportAllFromTxt(){
             let docDir = path.join(__dirname,"../export",doc.objectId);
             if(!fs.existsSync(docDir)) {fs.mkdirSync(docDir)};
             let urlPdf = doc.urlPdf;
-            let pdfPath = doc.pdfPath
             console.log(doc)
             // let targetPath = path.join(docDir,path.basename(pdfPath));
             // fs.copyFileSync(pdfPath,targetPath)