Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit c2a4559

Browse files
committed
Fix job consolidation in store
1 parent c1091c7 commit c2a4559

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

app/jobs/actions.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ export function GetJobDetails(job_id) {
4141
}
4242

4343
export function JobReturn(job_id, job) {
44-
store.set(['jobs', job_id], JobEventToJobStore(job.data));
44+
let path = ['jobs', job_id];
45+
let job_to_store = JobEventToJobStore(job.data);
46+
if(store.exists(path)) {
47+
store.merge(path, job_to_store);
48+
} else {
49+
store.set(path, job_to_store);
50+
}
4551
}
4652

4753
export function UpdateModuleFunctionList(job_id, minion, job) {
@@ -91,6 +97,18 @@ export function RunJob(matcher, minions, module_function, args, add_to_runned_jo
9197
store.apply(['session', 'runned_jobs'], _.partial(last10, job_id));
9298
}
9399

100+
// Add to store informations we have
101+
let job = {Function: module_function, jid: job_id,
102+
Target: minions, Arguments: args,
103+
'Target-type': matcher}
104+
105+
let path = ['jobs', job_id]
106+
if(store.exists(path)) {
107+
store.merge(path, job);
108+
} else {
109+
store.set(path, job);
110+
}
111+
94112
return job_id;
95113
});
96114
}

app/jobs/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export var JobEventToJobStore = function(job) {
1212
'StartTime': moment(job['_stamp'], moment.ISO_8601).unix(), 'Target': job['tgt'],
1313
'Target-type': job['tgt_type'], 'Arguments': ArgParser(job['arg']),
1414
'Minions': job['minions'], 'Return': job['return']}
15-
return _.omit(new_job, _.isUndefined);
15+
return _.omitBy(new_job, _.isUndefined);
1616
}
1717

1818
export var ArgSpecParser = function(argspec) {

0 commit comments

Comments
 (0)