Browse Source

应用告警查询接口

dev
巴林闲侠 2 years ago
parent
commit
4b2ce5d77a
  1. 20
      api/app/lib/controllers/alarm/app.js

20
api/app/lib/controllers/alarm/app.js

@ -198,7 +198,7 @@ async function apiErrorList (ctx) {
$or: [] $or: []
}, },
include: [{ include: [{
model: models.ProjectApp, model: models.App,
where: { where: {
}, },
@ -225,10 +225,10 @@ async function apiErrorList (ctx) {
if (projectRes.length) { if (projectRes.length) {
findOption.where.$or.push( findOption.where.$or.push(
{ {
'$projectApp.projectCorrelation.pep_project_id$': { '$app->projectCorrelations.pep_project_id$': {
$in: projectRes.map(p => p.id) $in: projectRes.map(p => p.id)
}, },
'$projectApp.name$': { $like: `%${keyword}%` } '$app.name$': { $like: `%${keyword}%` }
} }
) )
} }
@ -276,8 +276,10 @@ async function apiErrorList (ctx) {
// 没有关键字筛选 查询关联的项目信息 // 没有关键字筛选 查询关联的项目信息
let pepProjectIds = new Set() let pepProjectIds = new Set()
for (let lr of listRes.rows) { for (let lr of listRes.rows) {
if (lr.projectApp && lr.projectApp.projectCorrelation) { if (lr.app && lr.app.projectCorrelations) {
pepProjectIds.add(lr.projectApp.projectCorrelation.pepProjectId) for (let p of lr.app.projectCorrelations) {
pepProjectIds.add(p.pepProjectId)
}
} }
} }
if (pepProjectIds.size) { if (pepProjectIds.size) {
@ -289,10 +291,12 @@ async function apiErrorList (ctx) {
} }
for (let lr of listRes.rows) { for (let lr of listRes.rows) {
if (lr.projectApp && lr.projectApp.projectCorrelation) { if (lr.app && lr.app.projectCorrelations) {
let corPepProject = projectRes.find(p => p.id == lr.projectApp.projectCorrelation.pepProjectId) for (let p of lr.app.projectCorrelations) {
let corPepProject = projectRes.find(pr => pr.id == p.pepProjectId)
if (corPepProject) { if (corPepProject) {
lr.projectApp.projectCorrelation.dataValues.pepProject = corPepProject p.dataValues.pepProject = corPepProject
}
} }
} }
} }

Loading…
Cancel
Save