Browse Source

数据告警项目名称筛选

dev
巴林闲侠 2 years ago
parent
commit
38aa24b5e3
  1. 22
      api/app/lib/utils/dataRange.js

22
api/app/lib/utils/dataRange.js

@ -34,6 +34,18 @@ module.exports = function (app, opts) {
findOption.where.id = { $in: correlationProject }
}
let pepProjectWhereOptions = []
if (keywordTarget == 'pepProject' && keyword) {
pepProjectWhereOptions.push(`t_pim_project.project_name LIKE '%${keyword}%'`)
findOption.where.name = {
$or: [{
$eq: null
}, {
$like: `%${keyword}%`
}]
}
}
// TODO 这儿也许需要判断传进来的 pepProjectId 在不在当前用户的关注范围内
// 根据 poms 的项目绑定关系查相关联的项企项目、安心云项目id信息
const bindRes = await models.ProjectCorrelation.findAll(findOption)
@ -46,10 +58,7 @@ module.exports = function (app, opts) {
}
}
// 查询项企项目的信息
let pepProjectWhereOptions = []
if (keywordTarget == 'pepProject' && keyword) {
pepProjectWhereOptions.push(`t_pim_project.project_name LIKE '%${keyword}%'`)
}
const pepProjectRes = pepProjectIds.length ?
await clickHouse.projectManage.query(
`
@ -77,8 +86,9 @@ module.exports = function (app, opts) {
// 获取不重复的 安心云项目 id
const anxinProjectIds = [
...(
// bindRes.filter(b => pepProjectRes.some(pp => pp.id == b.pepProjectId))
bindRes
keywordTarget == 'pepProject' && keyword ?
bindRes.filter(b => b.name || pepProjectRes.some(pp => pp.id == b.pepProjectId)) :
bindRes
).reduce(
(arr, b) => {
for (let sid of b.anxinProjectId) {

Loading…
Cancel
Save