MCPcopy
hub / github.com/chartbrew/chartbrew / update

Function update

server/controllers/AlertController.js:51–86  ·  view source on GitHub ↗
(id, data)

Source from the content-addressed store, hash-verified

49}
50
51function update(id, data) {
52 return db.Alert.update(data, {
53 where: {
54 id,
55 },
56 })
57 .then(() => {
58 return findById(id);
59 })
60 .then(async (alert) => {
61 if (data.alertIntegrations) {
62 data.alertIntegrations.forEach((ai) => {
63 const foundIntegration = alert.AlertIntegrations.find((alertIntegration) => {
64 return alertIntegration.id === ai.id;
65 });
66
67 if (foundIntegration) {
68 db.AlertIntegration.update({
69 enabled: ai.enabled,
70 }, {
71 where: {
72 id: foundIntegration.id,
73 },
74 });
75 } else {
76 db.AlertIntegration.create({
77 alert_id: alert.id,
78 integration_id: ai.integration_id,
79 enabled: ai.enabled,
80 });
81 }
82 });
83 }
84 return findById(id);
85 });
86}
87
88function remove(id) {
89 return db.Alert.destroy({

Callers 1

TableConfigurationFunction · 0.50

Calls 3

findByIdFunction · 0.70
updateMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected