Library panels: Ensure pagination controls are always correctly displayed (#65283)

correctly count library panels in the general folder
This commit is contained in:
Ashley Harrison 2023-04-11 14:16:20 +01:00 committed by GitHub
parent 02a8bc76d2
commit fda38de293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -422,8 +422,19 @@ func (l *LibraryElementService) getAllLibraryElements(c context.Context, signedI
var libraryElements []model.LibraryElement
countBuilder := db.SQLBuilder{}
countBuilder.Write("SELECT * FROM library_element AS le")
countBuilder.Write(" INNER JOIN dashboard AS dashboard on le.folder_id = dashboard.id")
if folderFilter.includeGeneralFolder {
countBuilder.Write(selectLibraryElementDTOWithMeta)
countBuilder.Write(getFromLibraryElementDTOWithMeta(l.SQLStore.GetDialect()))
countBuilder.Write(` WHERE le.org_id=? AND le.folder_id=0`, signedInUser.OrgID)
writeKindSQL(query, &countBuilder)
writeSearchStringSQL(query, l.SQLStore, &countBuilder)
writeExcludeSQL(query, &countBuilder)
writeTypeFilterSQL(typeFilter, &countBuilder)
countBuilder.Write(" UNION ")
}
countBuilder.Write(selectLibraryElementDTOWithMeta)
countBuilder.Write(getFromLibraryElementDTOWithMeta(l.SQLStore.GetDialect()))
countBuilder.Write(" INNER JOIN dashboard AS dashboard on le.folder_id = dashboard.id and le.folder_id<>0")
countBuilder.Write(` WHERE le.org_id=?`, signedInUser.OrgID)
writeKindSQL(query, &countBuilder)
writeSearchStringSQL(query, l.SQLStore, &countBuilder)