Fixed timeline query for user+project combo
This commit is contained in:
parent
f9ada49278
commit
a602e02c9c
|
@ -129,10 +129,12 @@ func FetchTimeline(
|
|||
WHERE TRUE
|
||||
`,
|
||||
)
|
||||
if len(q.ProjectIDs)+len(q.OwnerIDs) > 0 {
|
||||
qb.Add(`AND (`)
|
||||
if len(q.ProjectIDs) > 0 {
|
||||
qb.Add(
|
||||
`
|
||||
AND (
|
||||
(
|
||||
SELECT count(*)
|
||||
FROM snippet_project
|
||||
WHERE
|
||||
|
@ -143,6 +145,16 @@ func FetchTimeline(
|
|||
`,
|
||||
q.ProjectIDs,
|
||||
)
|
||||
} else {
|
||||
qb.Add("FALSE")
|
||||
}
|
||||
qb.Add(" OR ")
|
||||
if len(q.OwnerIDs) > 0 {
|
||||
qb.Add(`owner_id = ANY($?)`, q.OwnerIDs)
|
||||
} else {
|
||||
qb.Add("FALSE")
|
||||
}
|
||||
qb.Add(`)`)
|
||||
}
|
||||
qb.Add(
|
||||
`
|
||||
|
@ -169,8 +181,20 @@ func FetchTimeline(
|
|||
WHERE post.deleted = false AND thread.deleted = false
|
||||
`,
|
||||
)
|
||||
if len(q.OwnerIDs)+len(q.ProjectIDs) > 0 {
|
||||
qb.Add(`AND (`)
|
||||
if len(q.ProjectIDs) > 0 {
|
||||
qb.Add(`AND post.project_id = ANY($?)`, q.ProjectIDs)
|
||||
qb.Add(`post.project_id = ANY($?)`, q.ProjectIDs)
|
||||
} else {
|
||||
qb.Add("FALSE")
|
||||
}
|
||||
qb.Add(" OR ")
|
||||
if len(q.OwnerIDs) > 0 {
|
||||
qb.Add(`post.author_id = ANY($?)`, q.OwnerIDs)
|
||||
} else {
|
||||
qb.Add("FALSE")
|
||||
}
|
||||
qb.Add(`)`)
|
||||
}
|
||||
qb.Add(
|
||||
`
|
||||
|
@ -192,10 +216,6 @@ func FetchTimeline(
|
|||
`,
|
||||
)
|
||||
|
||||
if len(q.OwnerIDs) > 0 {
|
||||
qb.Add(`AND owner_id = ANY($?)`, q.OwnerIDs)
|
||||
}
|
||||
|
||||
if currentUser == nil {
|
||||
qb.Add(
|
||||
`AND owner.status = $? -- snippet owner is Approved`,
|
||||
|
|
Loading…
Reference in New Issue