Skip to content

Commit

Permalink
Improved docs
Browse files Browse the repository at this point in the history
Signed-off-by: Arnau Mora Gras <[email protected]>
  • Loading branch information
ArnyminerZ authored and rfc2822 committed Jan 10, 2025
1 parent e485d4f commit 39680ee
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions app/src/main/kotlin/at/bitfire/davdroid/ui/DebugInfoModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,26 @@ class DebugInfoModel @AssistedInject constructor(
return table.toString()
}

private fun syncWorkersInfoTable(
/**
* Generates a table to display worker statuses.
*
* By default, the table provides the following columns:
* Tags, State, Next run, Retries, Generation, Periodicity
*
* If more tables are desired, they can be added using [extraColumns].
*
* The key of the map is the position of the column relative to the default ones, so for example,
* if a column is going to be added between "State" and "Next run", the index should be `2`.
*
* The value the map is a pair whose first element is the column name, and the second one is
* the generator of the value.
* The generator will be called on every worker info found after running the query, and should
* return a String that will be placed in the cell.
*
* @param query The query to use for fetching the workers.
* @param extraColumns Defaults to an empty map, pass extra columns to be added to the table.
*/
private fun workersInfoTable(
query: WorkQuery,
extraColumns: Map<Int, Pair<String, (WorkInfo) -> String>> = emptyMap()
): String {
Expand Down Expand Up @@ -605,7 +624,7 @@ class DebugInfoModel @AssistedInject constructor(
* whether they exist one by one
*/
private fun dumpSyncWorkersInfo(account: Account): String =
syncWorkersInfoTable(
workersInfoTable(
WorkQuery.Builder.fromTags(
SyncDataType.entries.map { BaseSyncWorker.commonTag(account, it) }
).build(),
Expand All @@ -630,7 +649,7 @@ class DebugInfoModel @AssistedInject constructor(
* whether they exist one by one
*/
private fun dumpSyncWorkersInfo(): String =
syncWorkersInfoTable(
workersInfoTable(
WorkQuery.Builder.fromUniqueWorkNames(
listOf(AccountsCleanupWorker.NAME)
).build()
Expand Down

0 comments on commit 39680ee

Please sign in to comment.