Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added new object nInput_FilesProcessed with the following options:

attrName (results to be presented, available options are: FilesProcessedByHour, FilesProcessedByDay, FilesInErrorByHour, FilesInErrorByDay, FilesProcessedMoreThanOnce, FilesBacklog)
chKeys (the channel of keys to use)\
key (the key for the database access)\
key.parent (in alternative provide the parent key (e.g. RAS))\
key.child (in alternative provide the child key synonym (e.g. db.app))\
dontUseKey (boolean to indicate if a key field should not be added in all records returned with chKeys)
number (number of days/hours ago the files were processed/errored out)

Changed the io.readFileYAML(var_yaml_file); to be used only once.
  • Loading branch information
abrizida committed Mar 13, 2024
1 parent 37fefb5 commit d2dfb7f
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions config/objects/nInput_FilesProcessed.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* - number (number of days/hours ago the files were processed/errored out)
* </odoc>
*/
var var_yaml_file = nattrmon.getConfigPath("objects.assets/ninputfilesprocessed/") + "/objects.assets/ninputfilesprocessed/nInput_FilesProcessed_config.yml"

var nInput_FilesProcessed = function(aMap) {
if (!isNull(aMap) && isMap(aMap)) {
Expand All @@ -23,21 +22,23 @@ var nInput_FilesProcessed = function(aMap) {
}
this.params.dontUseKey = _$(this.params.dontUseKey, "dontUseKey").isBoolean().default(isDef(this.params.key))


try {
var attributeObject = io.readFileYAML(var_yaml_file);
} catch (e) {
logErr("nInput_FilesProcessed | MAIN: Error reading configuration file from " + var_yaml_file + ".")
throw e
}

if (isUnDef(this.params.attrName))
{
logErr("nInput_FilesProcessed | MAIN: You need to provide the attrName (Attribute Name).")
return 0
}

if (isUnDef(attributeObject[this.params.attrName].name))
this.var_yaml_file = nattrmon.getConfigPath("objects.assets/ninputfilesprocessed/") + "/objects.assets/ninputfilesprocessed/nInput_FilesProcessed_config.yml"

try {
this.attributeObject = io.readFileYAML(this.var_yaml_file);
} catch (e) {
logErr("nInput_FilesProcessed | MAIN: Error reading configuration file from " + this.var_yaml_file + ".")
throw e
}

if (isUnDef(this.attributeObject[this.params.attrName].name))
{
logErr("nInput_FilesProcessed | MAIN: Cannot find configuration for attrName " + this.params.attrName + ".")
return 0
Expand All @@ -50,9 +51,9 @@ var nInput_FilesProcessed = function(aMap) {

if (isUnDef(this.params.attrTemplate))
if (isDef(this.params.key))
this.params.attrTemplate = "RAID/" + attributeObject[this.params.attrName].name
this.params.attrTemplate = "RAID/" + this.attributeObject[this.params.attrName].name
else
this.params.attrTemplate = "RAID/DB {{key}}/" + attributeObject[this.params.attrName].name
this.params.attrTemplate = "RAID/DB {{key}}/" + this.attributeObject[this.params.attrName].name

nInput.call(this, this.input)
}
Expand All @@ -61,10 +62,10 @@ inherit(nInput_FilesProcessed, nInput)
nInput_FilesProcessed.prototype.get = function(aKey, parent, ret, scope) {
var parent2 = parent
try {
var queries = io.readFileYAML(var_yaml_file);
var queries = this.attributeObject;
queries = queries[parent.attrName];
} catch (e) {
logErr("nInput_FilesProcessed | GET: Error reading configuration file from " + var_yaml_file + ".")
logErr("nInput_FilesProcessed | GET: Error reading configuration file from " + this.var_yaml_file + ".")
throw e
}

Expand Down

0 comments on commit d2dfb7f

Please sign in to comment.