|
@@ -26,94 +26,94 @@ async function processTask(){
|
|
|
}
|
|
|
let FilterConfig = await redis_help.getKeyValue("FilterConfig")
|
|
|
FilterConfig = JSON.parse(FilterConfig)
|
|
|
- result = await filter_data_controllers.getFilterDataByStatusAndLimit({ status: 0 , tg_platform_id: config.platform_dianzhong },500);
|
|
|
- if(result.success){
|
|
|
- let ProductIds = []
|
|
|
- let FilterList = []
|
|
|
- for (let index = 0; index < result.data.length; index++) {
|
|
|
- let filter_item = result.data[index];
|
|
|
- ProductIds.push(filter_item.book_id)
|
|
|
- FilterList[filter_item.book_id] = filter_item
|
|
|
- }
|
|
|
+ // result = await filter_data_controllers.getFilterDataByStatusAndLimit({ status: 0 , tg_platform_id: config.platform_dianzhong },500);
|
|
|
+ // if(result.success){
|
|
|
+ // let ProductIds = []
|
|
|
+ // let FilterList = []
|
|
|
+ // for (let index = 0; index < result.data.length; index++) {
|
|
|
+ // let filter_item = result.data[index];
|
|
|
+ // ProductIds.push(filter_item.book_id)
|
|
|
+ // FilterList[filter_item.book_id] = filter_item
|
|
|
+ // }
|
|
|
|
|
|
- console.log("ProductIds:",ProductIds)
|
|
|
+ // console.log("ProductIds:",ProductIds)
|
|
|
|
|
|
- let product_list_result = await video_product_controllers.findNonExistentProductIds(ProductIds);
|
|
|
+ // let product_list_result = await video_product_controllers.findNonExistentProductIds(ProductIds);
|
|
|
|
|
|
- if(product_list_result.success){
|
|
|
+ // if(product_list_result.success){
|
|
|
|
|
|
- for (let index = 0; index < result.data.length; index++) {
|
|
|
- let filter_item = result.data[index];
|
|
|
- if(product_list_result.data.existingProductIds.has(filter_item.book_id)){
|
|
|
- let info = FilterList[filter_item.book_id];
|
|
|
- let product_item = getProductById(product_list_result.data.existingRecords,filter_item.book_id)
|
|
|
- if (!info) {
|
|
|
- throw `No filter info found for book_id: ${filter_item.book_id}`
|
|
|
- }
|
|
|
- if (!product_item) {
|
|
|
- throw `product_item is null: ${filter_item.book_id}`
|
|
|
- }
|
|
|
- info.words = product_item.words
|
|
|
- info.genre = product_item.genre
|
|
|
- info.book_id = product_item.product_id
|
|
|
- info.book_name = product_item.product_name
|
|
|
- await CMD.update_filter_data(FilterConfig,info)
|
|
|
- await new Promise(resolve => setTimeout(resolve,100));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let Ids = []
|
|
|
- for (let index = 0; index < product_list_result.data.nonExistentIds.length; index++) {
|
|
|
- const product_id = product_list_result.data.nonExistentIds[index];
|
|
|
- Ids.push(FilterList[product_id].id)
|
|
|
- task_queue.push({result:{data:FilterList[product_id]}})
|
|
|
- }
|
|
|
- console.log("Ids:",Ids)
|
|
|
- if(Ids.length>0){
|
|
|
- await filter_data_controllers.updateFilterDataByIds({ids:Ids},{status:1})
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }catch(e){
|
|
|
- console.error("processTask:",e)
|
|
|
- } finally{
|
|
|
- global.setTimeout(processTask, 100);
|
|
|
- }
|
|
|
+ // for (let index = 0; index < result.data.length; index++) {
|
|
|
+ // let filter_item = result.data[index];
|
|
|
+ // if(product_list_result.data.existingProductIds.has(filter_item.book_id)){
|
|
|
+ // let info = FilterList[filter_item.book_id];
|
|
|
+ // let product_item = getProductById(product_list_result.data.existingRecords,filter_item.book_id)
|
|
|
+ // if (!info) {
|
|
|
+ // throw `No filter info found for book_id: ${filter_item.book_id}`
|
|
|
+ // }
|
|
|
+ // if (!product_item) {
|
|
|
+ // throw `product_item is null: ${filter_item.book_id}`
|
|
|
+ // }
|
|
|
+ // info.words = product_item.words
|
|
|
+ // info.genre = product_item.genre
|
|
|
+ // info.book_id = product_item.product_id
|
|
|
+ // info.book_name = product_item.product_name
|
|
|
+ // await CMD.update_filter_data(FilterConfig,info)
|
|
|
+ // await new Promise(resolve => setTimeout(resolve,100));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- // let isInsertTask = false
|
|
|
- // result = await filter_data_controllers.getFilterDataByStatus({ status: 0 , tg_platform_id: config.platform_dianzhong });
|
|
|
- // if(result.success){
|
|
|
- // let tg_platform_id = result.data.tg_platform_id
|
|
|
- // //判断是否存在这本书
|
|
|
- // if(tg_platform_id==config.platform_dianzhong){ //点众
|
|
|
- // let dz_book_result = await video_product_controllers.getProductData({ book_id: result.data.book_id });
|
|
|
- // if(dz_book_result.success){
|
|
|
- // result.data.words = dz_book_result.data.words
|
|
|
- // result.data.genre = dz_book_result.data.genre
|
|
|
- // result.data.book_id = dz_book_result.data.product_id
|
|
|
- // result.data.book_name = dz_book_result.data.product_name
|
|
|
- // }else{
|
|
|
- // isInsertTask = true
|
|
|
+ // let Ids = []
|
|
|
+ // for (let index = 0; index < product_list_result.data.nonExistentIds.length; index++) {
|
|
|
+ // const product_id = product_list_result.data.nonExistentIds[index];
|
|
|
+ // Ids.push(FilterList[product_id].id)
|
|
|
+ // task_queue.push({result:{data:FilterList[product_id]}})
|
|
|
// }
|
|
|
+ // console.log("Ids:",Ids)
|
|
|
+ // if(Ids.length>0){
|
|
|
+ // await filter_data_controllers.updateFilterDataByIds({ids:Ids},{status:1})
|
|
|
+ // }
|
|
|
+
|
|
|
// }
|
|
|
- // if(!isInsertTask){
|
|
|
- // await CMD.update_filter_data(FilterConfig,result.data)
|
|
|
- // }else{
|
|
|
- // await filter_data_controllers.updateFilterData({id:result.data.id},{status:1})
|
|
|
- // task_queue.push({result:result})
|
|
|
- // }
|
|
|
+
|
|
|
// }
|
|
|
// }catch(e){
|
|
|
- // console.error("processTask error:",e)
|
|
|
- // // if(result!=null&&result!=undefined){
|
|
|
- // // await filter_data_controllers.updateFilterData({id:result.data.id},{status:2})
|
|
|
- // // }
|
|
|
+ // console.error("processTask:",e)
|
|
|
// } finally{
|
|
|
// global.setTimeout(processTask, 100);
|
|
|
// }
|
|
|
|
|
|
+ let isInsertTask = false
|
|
|
+ result = await filter_data_controllers.getFilterDataByStatus({ status: 0 , tg_platform_id: config.platform_dianzhong });
|
|
|
+ if(result.success){
|
|
|
+ let tg_platform_id = result.data.tg_platform_id
|
|
|
+ //判断是否存在这本书
|
|
|
+ if(tg_platform_id==config.platform_dianzhong){ //点众
|
|
|
+ let dz_book_result = await video_product_controllers.getProductData({ book_id: result.data.book_id });
|
|
|
+ if(dz_book_result.success){
|
|
|
+ result.data.words = dz_book_result.data.words
|
|
|
+ result.data.genre = dz_book_result.data.genre
|
|
|
+ result.data.book_id = dz_book_result.data.product_id
|
|
|
+ result.data.book_name = dz_book_result.data.product_name
|
|
|
+ }else{
|
|
|
+ isInsertTask = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!isInsertTask){
|
|
|
+ await CMD.update_filter_data(FilterConfig,result.data)
|
|
|
+ }else{
|
|
|
+ await filter_data_controllers.updateFilterData({id:result.data.id},{status:1})
|
|
|
+ task_queue.push({result:result})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+ console.error("processTask error:",e)
|
|
|
+ // if(result!=null&&result!=undefined){
|
|
|
+ // await filter_data_controllers.updateFilterData({id:result.data.id},{status:2})
|
|
|
+ // }
|
|
|
+ } finally{
|
|
|
+ global.setTimeout(processTask, 100);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
async function processCreateTask(){
|