Skip to content

Commit

Permalink
Merge pull request #225 from c-bata/datagrid-less-comparator
Browse files Browse the repository at this point in the history
Porting optuna-dashboard patches to Goptuna.
  • Loading branch information
c-bata authored Apr 23, 2021
2 parents 56bbce2 + e8d4a3c commit e3e51ee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:14.15.4 AS front-builder

RUN mkdir -p /usr/src/
RUN mkdir -p /usr/src/public/
WORKDIR /usr/src

ADD ./package.json /usr/src/package.json
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/components/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface DataGridColumn<T> {
field: keyof T
label: string
sortable?: boolean
less?: (i: number, j: number) => number
less?: (a: T, b: T) => number
filterable?: boolean
toCellValue?: (rowIndex: number) => string | React.ReactNode
padding?: "default" | "checkbox" | "none"
Expand Down Expand Up @@ -342,7 +342,7 @@ function stableSort<T>(
const stabilizedThis = array.map((el, index) => [el, index] as [T, number])
stabilizedThis.sort((a, b) => {
if (less) {
const result = order == "asc" ? -less(a[1], b[1]) : less(a[1], b[1])
const result = order == "asc" ? -less(a[0], b[0]) : less(a[0], b[0])
if (result !== 0) return result
} else {
const result = comparator(a[0], b[0])
Expand Down
10 changes: 5 additions & 5 deletions dashboard/src/components/StudyDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ const TrialTable: FC<{ trials: Trial[] }> = ({ trials = [] }) => {
return null
},
sortable: true,
less: (i, j): number => {
const firstStartMs = trials[i].datetime_start?.getTime()
const firstCompleteMs = trials[i].datetime_complete?.getTime()
less: (firstEl, secondEl): number => {
const firstStartMs = firstEl.datetime_start?.getTime()
const firstCompleteMs = firstEl.datetime_complete?.getTime()
const firstDurationMs =
firstStartMs !== undefined && firstCompleteMs !== undefined
? firstCompleteMs - firstStartMs
: undefined
const secondStartMs = trials[j].datetime_start?.getTime()
const secondCompleteMs = trials[j].datetime_complete?.getTime()
const secondStartMs = secondEl.datetime_start?.getTime()
const secondCompleteMs = secondEl.datetime_complete?.getTime()
const secondDurationMs =
secondStartMs !== undefined && secondCompleteMs !== undefined
? secondCompleteMs - secondStartMs
Expand Down
2 changes: 1 addition & 1 deletion dashboard/statik/statik.go

Large diffs are not rendered by default.

0 comments on commit e3e51ee

Please sign in to comment.