mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-11 12:30:25 +08:00
fix by review
This commit is contained in:
@@ -17,8 +17,7 @@ import ListItemText from "@mui/material/ListItemText"
|
||||
import {
|
||||
drawerOpenState,
|
||||
reloadIntervalState,
|
||||
useStudyDetailValue,
|
||||
useStudySummaryValue,
|
||||
useStudyIsPreferencial,
|
||||
} from "../state"
|
||||
import { Link } from "react-router-dom"
|
||||
import AutoGraphIcon from "@mui/icons-material/AutoGraph"
|
||||
@@ -130,12 +129,8 @@ export const AppDrawer: FC<{
|
||||
const action = actionCreator()
|
||||
const [open, setOpen] = useRecoilState<boolean>(drawerOpenState)
|
||||
const reloadInterval = useRecoilValue<number>(reloadIntervalState)
|
||||
const studyDetail =
|
||||
studyId !== undefined ? useStudyDetailValue(studyId) : null
|
||||
const studySummary =
|
||||
studyId !== undefined ? useStudySummaryValue(studyId) : null
|
||||
const isPreferential =
|
||||
studyDetail?.is_preferential ?? studySummary?.is_preferential ?? false
|
||||
studyId !== undefined ? useStudyIsPreferencial(studyId) : null
|
||||
|
||||
const styleListItem = {
|
||||
display: "block",
|
||||
@@ -248,7 +243,7 @@ export const AppDrawer: FC<{
|
||||
<ListItemText primary="Analytics" sx={styleListItemText} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
{studyDetail?.is_preferential && (
|
||||
{isPreferential && (
|
||||
<ListItem key="PreferenceGraph" disablePadding sx={styleListItem}>
|
||||
<ListItemButton
|
||||
component={Link}
|
||||
|
||||
@@ -94,9 +94,9 @@ const defaultEdgeOptions: DefaultEdgeOptions = {
|
||||
animated: true,
|
||||
}
|
||||
|
||||
function reductionPreference(
|
||||
const reductionPreference = (
|
||||
input_preferences: [number, number][]
|
||||
): [number, number][] {
|
||||
): [number, number][] => {
|
||||
const preferences: [number, number][] = []
|
||||
let n = 0
|
||||
for (const [source, target] of input_preferences) {
|
||||
|
||||
@@ -18,8 +18,8 @@ import { actionCreator } from "../action"
|
||||
import {
|
||||
reloadIntervalState,
|
||||
useStudyDetailValue,
|
||||
useStudyIsPreferencial,
|
||||
useStudyName,
|
||||
useStudySummaryValue,
|
||||
} from "../state"
|
||||
import { TrialTable } from "./TrialTable"
|
||||
import { AppDrawer, PageId } from "./AppDrawer"
|
||||
@@ -52,11 +52,9 @@ export const StudyDetail: FC<{
|
||||
const action = actionCreator()
|
||||
const studyId = useURLVars()
|
||||
const studyDetail = useStudyDetailValue(studyId)
|
||||
const studySummary = useStudySummaryValue(studyId)
|
||||
const reloadInterval = useRecoilValue<number>(reloadIntervalState)
|
||||
const studyName = useStudyName(studyId)
|
||||
const isPreferential =
|
||||
studySummary?.is_preferential ?? studyDetail?.is_preferential ?? false
|
||||
const isPreferential = useStudyIsPreferencial(studyId)
|
||||
|
||||
const title =
|
||||
studyName !== null ? `${studyName} (id=${studyId})` : `Study #${studyId}`
|
||||
|
||||
@@ -87,6 +87,12 @@ export const useStudyDirections = (
|
||||
return studyDetail?.directions || studySummary?.directions || null
|
||||
}
|
||||
|
||||
export const useStudyIsPreferencial = (studyId: number): boolean | null => {
|
||||
const studyDetail = useStudyDetailValue(studyId)
|
||||
const studySummary = useStudySummaryValue(studyId)
|
||||
return studyDetail?.is_preferential || studySummary?.is_preferential || null
|
||||
}
|
||||
|
||||
export const useStudyName = (studyId: number): string | null => {
|
||||
const studyDetail = useStudyDetailValue(studyId)
|
||||
const studySummary = useStudySummaryValue(studyId)
|
||||
|
||||
Reference in New Issue
Block a user