Skip to content

Commit

Permalink
gubfiw _id not objectId in data
Browse files Browse the repository at this point in the history
  • Loading branch information
simon louvet committed Nov 20, 2023
1 parent 28a8931 commit 598f8ff
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 47 deletions.
20 changes: 9 additions & 11 deletions core/lib/fragment_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,16 @@ module.exports = {
},

testAllLiteralArray: function (arrayToTest){
const allLiteral = arrayToTest.every(i=>{
const isLiteral = this.isLiteral(i);
// console.log('is literal',i,isLiteral)
return isLiteral
const oneNotLiteral = arrayToTest.some(i=>{
const isNotLiteral = !this.isLiteral(i);
return isNotLiteral
})
return allLiteral
return !oneNotLiteral

},

testFragArray: function (arrayToTest){
if (arrayToTest.length<=1000){
if (arrayToTest.length<=100){
return false;
}else if (this.testAllLiteralArray(arrayToTest)){
return false
Expand Down Expand Up @@ -402,13 +401,13 @@ module.exports = {
if (this.isLiteral(data)){
return this.processLiteral(data);
} else if (Array.isArray(data) && this.testFragArray(data)){
// console.log(('object->frag'));
console.log(('object->frag'));
return await this.persist (data,fragCaller,exitingFrag)
} else {
for (let key in data) {
// console.log('persist key ',key,'value',data[key])
// console.log('persist key ',key)
const persistReturn = await this.persistObject(data[key],fragCaller);
if (persistReturn?._id){
if (persistReturn?._id && persistReturn?._id instanceof mongoose.Types.ObjectId){
data[key] = {
_frag : persistReturn._id.toString()
}
Expand Down Expand Up @@ -472,8 +471,7 @@ module.exports = {
_id: id
})
.lean()
.exec()
.then();
.exec();
// console.log('frag',fragmentReturn)
if (fragmentReturn.branchFrag) {
const frags = await this.fragmentModel.getInstance().model.find({
Expand Down
2 changes: 1 addition & 1 deletion engine/communication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Communication {
}).then( (data)=>{
console.log('work-ask',messageObject)
const engine = require('../services/engine.js')
console.log('messageObject',messageObject)
// console.log('messageObject',messageObject)
engine.execute(data, 'work', this.amqpClient, messageObject.callerId,messageObject.pushData,messageObject.queryParams, messageObject.tracerId).then(r=>{
// console.log('engine ok');
}).catch(e=>{
Expand Down
2 changes: 1 addition & 1 deletion engine/services/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class Engine {
try {
// console.log("in dataFlow",dataFlow);
const componentFlow= await module.pull(processingNode.component, dataFlow, processingNode.queryParams == undefined ? undefined : processingNode.queryParams.queryParams);
console.log('ENGINE Component ok')
// console.log('ENGINE Component ok')

const {
data,
Expand Down
37 changes: 19 additions & 18 deletions engine/workspaceComponentExecutor/cacheNosql.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,26 @@ class CacheNosql {
this.stepNode = true
}

initialise (router) {
router.get('/getCache/:compId', function (req, res, next) {
var compId = req.params.compId
// initialise (router) {
// router.get('/getCache/:compId', function (req, res, next) {

this.workspace_component_lib.get({
_id: compId
}).then(component => {
this.cache_lib.get(component, false).then(cachedData => {
if (cachedData != undefined) {
res.json(cachedData)
} else {
res.json([])
}
}).catch(e => {
next(e)
})
})
}.bind(this))
}
// var compId = req.params.compId

// this.workspace_component_lib.get({
// _id: compId
// }).then(component => {
// this.cache_lib.get(component, false).then(cachedData => {
// if (cachedData != undefined) {
// res.json(cachedData)
// } else {
// res.json([])
// }
// }).catch(e => {
// next(e)
// })
// })
// }.bind(this))
// }

pull (data, flowData, queryParams) {
return new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion engine/workspaceComponentExecutor/simpleAgregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SimpleAgregator {
}
pull (data, flowData) {
return new Promise((resolve, reject) => {
console.log('___',flowData)
// console.log('___',flowData)
var resultFlow = []
for (let flow of flowData) {
for(let oririnData of flow.data){
Expand Down
31 changes: 16 additions & 15 deletions main/server/workspaceComponentInitialize/cacheNosql.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ class CacheNosql {
}

initialise (router) {
router.get('/getCache/:compId', function (req, res, next) {
var compId = req.params.compId
router.get('/getCache/:compId', async function (req, res, next) {
try {
var compId = req.params.compId
const component = await this.workspace_component_lib.get({
_id: compId
});

this.workspace_component_lib.get({
_id: compId
}).then(component => {
this.cache_lib.get(component, false).then(cachedData => {
if (cachedData != undefined) {
res.json(cachedData)
} else {
res.json([])
}
}).catch(e => {
next(e)
})
})
const cachedData = await this.cache_lib.get(component, false);

if (cachedData != undefined) {
res.json(cachedData.data)
} else {
res.json([])
}
} catch (error) {
next(error)
}
}.bind(this))
}
}
Expand Down

0 comments on commit 598f8ff

Please sign in to comment.