Skip to content

Implemented sort order for DAV documents #1434

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

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3aaa870
Implemented sort order
ArnyminerZ May 2, 2025
d7bdcb0
Fixed column name
ArnyminerZ May 2, 2025
f1edf6e
Implemented sort order
ArnyminerZ May 2, 2025
5b905dc
Fixed column name
ArnyminerZ May 2, 2025
20e9391
Merge branch 'main-ose' into 1431-file-order-issue-when-accessing-aud…
ArnyminerZ May 10, 2025
39f9588
Merge remote-tracking branch 'origin/1431-file-order-issue-when-acces…
ArnyminerZ May 10, 2025
4de50e2
Improved issues
ArnyminerZ May 10, 2025
8e2ea85
Add test for WebDavDocumentDao.getChildren for ORDER BY
rfc2822 May 12, 2025
268ff49
Merge branch 'main-ose' into 1431-file-order-issue-when-accessing-aud…
ArnyminerZ May 13, 2025
f3095d5
Converted getChildren into a raw query
ArnyminerZ May 13, 2025
65af1a9
Fix formatting of SQL query in WebDavDocumentDao
rfc2822 May 14, 2025
3a5aae9
Refactoring
ArnyminerZ May 19, 2025
8245287
Drop comment
ArnyminerZ May 19, 2025
05dc9a6
Merge branch 'main-ose' into 1431-file-order-issue-when-accessing-aud…
ArnyminerZ May 19, 2025
fa2f7d7
Changed default sort to show directories first
ArnyminerZ May 19, 2025
4154091
Merge branch 'main-ose' into 1431-file-order-issue-when-accessing-aud…
ArnyminerZ May 19, 2025
32c354b
Fixed tests
ArnyminerZ May 19, 2025
8699634
Merge remote-tracking branch 'origin/1431-file-order-issue-when-acces…
ArnyminerZ May 19, 2025
1baa0e4
Switched to query constructor instead of in-place
ArnyminerZ May 20, 2025
50f6d48
Changed log method
ArnyminerZ May 20, 2025
dbcf233
Add DocumentSortByMapper to handle orderBy mapping for WebDavDocument…
rfc2822 May 21, 2025
0043732
Rename DavDocumentsProviderTest to DocumentSortByMapperTest and updat…
rfc2822 May 21, 2025
9e7d29c
Refactor sorting and mapping
rfc2822 May 21, 2025
a33ce92
Add "order by name" as last criterion
rfc2822 May 21, 2025
1eb59ae
Remove default sort order constant from DocumentSortByMapper and use …
rfc2822 May 21, 2025
0f9f1b4
Adapt comments
rfc2822 May 21, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import java.time.Instant
Index("parentId")
]
)
// If any column name is modified, also change it in [DavDocumentsProvider$queryChildDocuments]
data class WebDavDocument(

@PrimaryKey(autoGenerate = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ interface WebDavDocumentDao {
@Query("SELECT * FROM webdav_document WHERE parentId=:parentId")
fun getChildren(parentId: Long): List<WebDavDocument>

@Query("SELECT * FROM webdav_document WHERE parentId=:parentId ORDER BY :orderBy")
fun getChildrenOrdered(parentId: Long, orderBy: String): List<WebDavDocument>

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertOrReplace(document: WebDavDocument): Long

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,21 @@ class DavDocumentsProvider(
runningQueryChildren.remove(parentId)

// Regardless of whether the worker is done, return the children we already have
for (child in documentDao.getChildren(parentId)) {
val children = if (sortOrder == null) {
documentDao.getChildren(parentId)
} else {
documentDao.getChildrenOrdered(
parentId,
// Convert the cursor's column name into Room's
sortOrder
.replace(Document.COLUMN_DOCUMENT_ID, "id")
.replace(Document.COLUMN_DISPLAY_NAME, "displayName")
.replace(Document.COLUMN_MIME_TYPE, "mimeType")
.replace(Document.COLUMN_SIZE, "size")
.replace(Document.COLUMN_LAST_MODIFIED, "lastModified")
)
}
for (child in children) {
val bundle = child.toBundle(parent)
result.addRow(bundle)
}
Expand Down