Skip to content
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

🐛 Fix labelIDs() query ignoring other issue fields when labels included. #415

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions api/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -1275,30 +1275,29 @@ func (h *AnalysisHandler) appIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) {
var qs []*gorm.DB
for _, f = range f.Expand() {
f = f.As("TagID")
q := h.DB(ctx)
q = q.Model(&model.ApplicationTag{})
q = q.Select("applicationID ID")
q = f.Where(q)
qs = append(qs, q)
iq := h.DB(ctx)
iq = iq.Model(&model.ApplicationTag{})
iq = iq.Select("applicationID ID")
iq = f.Where(q)
qs = append(qs, iq)
}
tq := model.Intersect(qs...)
q = q.Where("ID IN (?)", tq)
q = q.Where("ID IN (?)", model.Intersect(qs...))
} else {
f = f.As("TagID")
tq := h.DB(ctx)
tq = tq.Model(&model.ApplicationTag{})
tq = tq.Select("ApplicationID ID")
tq = f.Where(tq)
q = q.Where("ID IN (?)", tq)
iq := h.DB(ctx)
iq = iq.Model(&model.ApplicationTag{})
iq = iq.Select("ApplicationID ID")
iq = f.Where(iq)
q = q.Where("ID IN (?)", iq)
}
}
bsFilter := f.Resource("businessService")
if !bsFilter.Empty() {
bq := h.DB(ctx)
bq = bq.Model(&model.BusinessService{})
bq = bq.Select("ID")
bq = bsFilter.Where(bq)
q = q.Where("ID IN (?)", bq)
iq := h.DB(ctx)
iq = iq.Model(&model.BusinessService{})
iq = iq.Select("ID")
iq = bsFilter.Where(iq)
q = q.Where("ID IN (?)", iq)
return
}
return
Expand Down Expand Up @@ -1330,21 +1329,22 @@ func (h *AnalysisHandler) issueIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) {
var qs []*gorm.DB
for _, f = range f.Expand() {
f = f.As("json_each.value")
q := h.DB(ctx)
q = q.Table("Issue")
q = q.Joins("m ,json_each(Labels)")
q = q.Select("m.ID")
q = f.Where(q)
qs = append(qs, q)
iq := h.DB(ctx)
iq = iq.Table("Issue")
iq = iq.Joins("m ,json_each(Labels)")
iq = iq.Select("m.ID")
iq = f.Where(iq)
qs = append(qs, iq)
}
q = model.Intersect(qs...)
q = q.Where("ID IN (?)", model.Intersect(qs...))
} else {
f = f.As("json_each.value")
q = h.DB(ctx)
q = q.Table("Issue")
q = q.Joins("m ,json_each(Labels)")
q = q.Select("m.ID")
q = f.Where(q)
iq := h.DB(ctx)
iq = iq.Table("Issue")
iq = iq.Joins("m ,json_each(Labels)")
iq = iq.Select("m.ID")
iq = f.Where(iq)
q = q.Where("ID IN (?)", iq)
}
}
return
Expand Down