MCPcopy
hub / github.com/chartbrew/chartbrew / create

Function create

server/controllers/AlertController.js:12–49  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

10}
11
12function create(data) {
13 return db.Alert.create(data)
14 .then((createdAlert) => {
15 return findById(createdAlert.id);
16 })
17 .then((alert) => {
18 if (data.alertIntegrations) {
19 data.alertIntegrations.forEach((ai) => {
20 const foundIntegration = alert.AlertIntegrations.find((alertIntegration) => {
21 return alertIntegration.id === ai.id;
22 });
23
24 if (foundIntegration) {
25 db.AlertIntegration.update({
26 enabled: ai.enabled,
27 }, {
28 where: {
29 id: foundIntegration.id,
30 },
31 });
32 } else {
33 db.AlertIntegration.create({
34 alert_id: alert.id,
35 integration_id: ai.integration_id,
36 enabled: ai.enabled,
37 });
38 }
39 });
40 }
41
42 return findById(alert.id);
43 })
44 .catch((err) => {
45 return new Promise((resolve, reject) => {
46 reject(err);
47 });
48 });
49}
50
51function update(id, data) {
52 return db.Alert.update(data, {

Callers

nothing calls this directly

Calls 3

findByIdFunction · 0.70
createMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected