OTTAA-Project / Realiser

Repository for OTTAA's realiser algorithm, previously known as NLG, used for the OTTAA Labs option on the app.
GNU General Public License v3.0
0 stars 0 forks source link

optimization of read operations #8

Closed lopezjuanma96 closed 2 years ago

lopezjuanma96 commented 2 years ago

one way to optimize the process, which is actually already pretty fast, is to store variables with data from firebase somewhere they can be accessed if needed. Like a middle point between calling them on every function:

function1(args) {
   const data = ref('db').get()
}
function2(args) {
   const data = ref('db').get()
}

and carrying them from the first function to the last one as parameters:

superfunction(argsFunc1, argsFunc2){
    const data = ref('db').get();
    function1(argsFunc1, data);
    function2(argsFunc2, data);
}
 function1(args, data) {
   const data = ref('db').get()
}
function2(args, data) {
   const data = ref('db').get()
}

maybe this can be done with a singleton that handles the variables and gets them from db only if they haven't been requested before (on that execution, obviously after the execution is done, data would be erased, but at least it's not local to each function)

lopezjuanma96 commented 2 years ago

created class dbGetter with static properties and methods (singleton) to get data if it hasn't been already retrieved before