зеркало из https://github.com/mozilla/mig.git
Establish a relationship between actions and the agents targeted by them when actions are inserted into postgres
This commit is contained in:
Родитель
f2e60c0403
Коммит
a611f5587c
|
@ -202,6 +202,19 @@ func (db *DB) InsertAction(a mig.Action) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to store action: '%v'", err)
|
return fmt.Errorf("Failed to store action: '%v'", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following query establishes a relation between the new action and all
|
||||||
|
// agents targeted by the action.
|
||||||
|
_, err = db.c.Exec(fmt.Sprintf(`
|
||||||
|
insert into agent_action_relation (agent_id, action_id)
|
||||||
|
select $1, A.id
|
||||||
|
from agents A
|
||||||
|
where (%s);
|
||||||
|
`, a.Target), a.ID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to establish relation between action and targeted agents: '%s'", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче