Browse Source

fix: export all status 400 tbook

ryanemax 3 tuần trước cách đây
mục cha
commit
2c15cba5a3
1 tập tin đã thay đổi với 21 bổ sung4 xóa
  1. 21 4
      server/cloud/tbook/test/test-export.js

+ 21 - 4
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};
@@ -113,6 +129,7 @@ async function exportAllFromTxt(){
     });
     // list = list.slice(0,1);
     console.log(list?.length)
+    return
     for (let index = 0; index < list.length; index++) {
         let id = list[index];
         console.log(index+1,id)