Skip to content

Commit

Permalink
Added sorting for numeric extras!
Browse files Browse the repository at this point in the history
  • Loading branch information
handstandsam committed Dec 3, 2024
1 parent d5297c5 commit b9d1cc4
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import com.squareup.invert.common.navigation.NavRouteRepo
import com.squareup.invert.common.navigation.routes.BaseNavRoute
import com.squareup.invert.common.pages.CodeReferencesNavRoute.Companion.parser
import com.squareup.invert.common.utils.FormattingUtils.formatEpochToDate
import com.squareup.invert.models.ExtraDataType
import com.squareup.invert.models.ExtraKey
import com.squareup.invert.models.ModulePath
import com.squareup.invert.models.OwnerName
import com.squareup.invert.models.StatDataType
import com.squareup.invert.models.StatKey
import com.squareup.invert.models.StatMetadata
import com.squareup.invert.models.js.StatTotalAndMetadata
import org.jetbrains.compose.web.dom.A
import org.jetbrains.compose.web.dom.H3
Expand Down Expand Up @@ -146,17 +148,20 @@ fun CodeReferencesComposable(
return
}

val statInfos = statInfosOrig!!

val historicalData = historicalDataOrig!!

val currentStatMetadata: StatMetadata? = statInfos.firstOrNull { it.key == codeReferencesNavRoute.statKey }

val metadata by reportDataRepo.reportMetadata.collectAsState(null)
BootstrapRow {
BootstrapColumn(8) {
H4 {
Text(buildString {
append("Code References")
codeReferencesNavRoute.statKey?.let { statKey ->
val statInfo = statInfosOrig?.filter { it.key == codeReferencesNavRoute.statKey }?.firstOrNull()
append(" for ${statInfo?.description ?: statKey} (${codeReferencesNavRoute.statKey})")
currentStatMetadata?.let {
append(" for ${currentStatMetadata.description} (${codeReferencesNavRoute.statKey})")
}
})
}
Expand Down Expand Up @@ -407,6 +412,14 @@ fun CodeReferencesComposable(
}
}

val extraTypes = currentStatMetadata?.extras?.map { extra ->
if (extra.type == ExtraDataType.NUMERIC) {
Int::class
} else {
String::class
}
} ?: emptyList()

BootstrapTable(
headers = listOf("Module", "Owner", "File", "Code") + extraKeys,
rows = filteredByOwner
Expand All @@ -422,7 +435,7 @@ fun CodeReferencesComposable(
maxResultsLimitConstant = PagingConstants.MAX_RESULTS,
sortAscending = true,
sortByColumn = 2,
types = listOf(String::class, String::class, String::class, String::class) + extraKeys.map { String::class }
types = listOf(String::class, String::class, String::class, String::class) + extraTypes
)
}
}

0 comments on commit b9d1cc4

Please sign in to comment.