-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: mutiple incidents #4986
base: master
Are you sure you want to change the base?
feat: mutiple incidents #4986
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ dist | |
dist-ssr | ||
*.local | ||
.idea | ||
.history/ | ||
|
||
/data | ||
!/data/.gitkeep | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,16 +106,10 @@ class StatusPage extends BeanModel { | |
static async getStatusPageData(statusPage) { | ||
const config = await statusPage.toPublicJSON(); | ||
|
||
// Incident | ||
let incident = await R.findOne("incident", " pin = 1 AND active = 1 AND status_page_id = ? ", [ | ||
statusPage.id, | ||
]); | ||
|
||
if (incident) { | ||
incident = incident.toPublicJSON(); | ||
} | ||
// Incident List | ||
const incidentList = await StatusPage.getIncidentList(statusPage.id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In cases such as these two lines, please use We know that this is an issue accross the app and that performance could be improved this way ^^ |
||
|
||
let maintenanceList = await StatusPage.getMaintenanceList(statusPage.id); | ||
const maintenanceList = await StatusPage.getMaintenanceList(statusPage.id); | ||
|
||
// Public Group List | ||
const publicGroupList = []; | ||
|
@@ -133,7 +127,7 @@ class StatusPage extends BeanModel { | |
// Response | ||
return { | ||
config, | ||
incident, | ||
incidentList, | ||
publicGroupList, | ||
maintenanceList, | ||
}; | ||
|
@@ -329,6 +323,29 @@ class StatusPage extends BeanModel { | |
return []; | ||
} | ||
} | ||
|
||
/** | ||
* Get list of incidents | ||
* @param {number} statusPageId ID of status page to get incidents for | ||
* @returns {object} Object representing incidents sanitized for public | ||
*/ | ||
static async getIncidentList(statusPageId) { | ||
try { | ||
const publicIncidentList = []; | ||
let incidentList = await R.find("incident", " pin = 1 AND active = 1 AND status_page_id = ? ", [ | ||
statusPageId, | ||
]); | ||
|
||
for (const incident of incidentList) { | ||
publicIncidentList.push(await incident.toPublicJSON()); | ||
} | ||
|
||
return publicIncidentList; | ||
|
||
} catch (error) { | ||
return []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you add a warning log here? (seems scarry to just ignore the error, I know that you did it to match the above) |
||
} | ||
} | ||
} | ||
|
||
module.exports = StatusPage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,6 @@ module.exports.statusPageSocketHandler = (socket) => { | |
throw new Error("slug is not found"); | ||
} | ||
|
||
await R.exec("UPDATE incident SET pin = 0 WHERE status_page_id = ? ", [ | ||
statusPageID | ||
]); | ||
|
||
let incidentBean; | ||
|
||
if (incident.id) { | ||
|
@@ -69,14 +65,15 @@ module.exports.statusPageSocketHandler = (socket) => { | |
} | ||
}); | ||
|
||
socket.on("unpinIncident", async (slug, callback) => { | ||
socket.on("unpinIncident", async (slug, incident, callback) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change this to be just the |
||
try { | ||
checkLogin(socket); | ||
|
||
let statusPageID = await StatusPage.slugToID(slug); | ||
|
||
await R.exec("UPDATE incident SET pin = 0 WHERE pin = 1 AND status_page_id = ? ", [ | ||
statusPageID | ||
await R.exec("UPDATE incident SET pin = 0 WHERE pin = 1 AND status_page_id = ? AND id = ? ", [ | ||
statusPageID, | ||
incident.id | ||
]); | ||
|
||
callback({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not find good docs what the folder does.
What does this ignore do?