@@ -18,38 +18,50 @@ import MacroBenchmarkTable from "@/common/MacroBenchmarkTable";
1818import { Button } from "@/components/ui/button" ;
1919import { Card , CardContent , CardHeader , CardTitle } from "@/components/ui/card" ;
2020import { Skeleton } from "@/components/ui/skeleton" ;
21- import { CompareData , MacroBenchmarkTableData } from "@/types" ;
21+ import { CompareData , MacroBenchmarkTableData , VitessRefs } from "@/types" ;
2222import useApiCall from "@/utils/Hook" ;
23- import { formatCompareData } from "@/utils/Utils" ;
23+ import { formatCompareData , getRefName } from "@/utils/Utils" ;
2424import { PlusCircledIcon } from "@radix-ui/react-icons" ;
2525import { useEffect , useState } from "react" ;
2626import { Link , useNavigate } from "react-router-dom" ;
2727import CompareHero from "./components/CompareHero" ;
2828
2929export default function Compare ( ) {
30+ const navigate = useNavigate ( ) ;
3031 const urlParams = new URLSearchParams ( window . location . search ) ;
3132
3233 const [ gitRef , setGitRef ] = useState ( {
3334 old : urlParams . get ( "old" ) || "" ,
3435 new : urlParams . get ( "new" ) || "" ,
3536 } ) ;
3637
37- const navigate = useNavigate ( ) ;
38-
39- useEffect ( ( ) => {
40- navigate ( `?old=${ gitRef . old } &new=${ gitRef . new } ` ) ;
41- } , [ gitRef . old , gitRef . new ] ) ;
42-
4338 const {
4439 data : data ,
4540 isLoading : isMacrobenchLoading ,
4641 error : macrobenchError ,
4742 } = useApiCall < CompareData [ ] > (
48- `${ import . meta. env . VITE_API_URL } macrobench/compare?new=${ gitRef . new } &old=${
49- gitRef . old
50- } `,
43+ gitRef . old && gitRef . new
44+ ? `${ import . meta. env . VITE_API_URL } macrobench/compare?new=${
45+ gitRef . new
46+ } &old=${ gitRef . old } `
47+ : ``
5148 ) ;
5249
50+ const { data : vitessRefs } = useApiCall < VitessRefs > (
51+ `${ import . meta. env . VITE_API_URL } vitess/refs`
52+ ) ;
53+
54+ useEffect ( ( ) => {
55+ let oldRefName = gitRef . old ;
56+ let newRefName = gitRef . new ;
57+ if ( vitessRefs ) {
58+ oldRefName = getRefName ( gitRef . old , vitessRefs ) ;
59+ newRefName = getRefName ( gitRef . new , vitessRefs ) ;
60+ }
61+
62+ navigate ( `?old=${ oldRefName } &new=${ newRefName } ` ) ;
63+ } , [ gitRef . old , gitRef . new , vitessRefs ] ) ;
64+
5365 let formattedData : MacroBenchmarkTableData [ ] = [ ] ;
5466
5567 if ( data !== null && data . length > 0 ) {
@@ -58,7 +70,11 @@ export default function Compare() {
5870
5971 return (
6072 < >
61- < CompareHero gitRef = { gitRef } setGitRef = { setGitRef } />
73+ < CompareHero
74+ gitRef = { gitRef }
75+ setGitRef = { setGitRef }
76+ vitessRefs = { vitessRefs }
77+ />
6278 { macrobenchError && (
6379 < div className = "text-red-500 text-center my-2" > { macrobenchError } </ div >
6480 ) }
@@ -75,6 +91,11 @@ export default function Compare() {
7591 } ) }
7692 </ >
7793 ) }
94+ { ! isMacrobenchLoading && data === null && (
95+ < div className = "md:text-xl text-primary" >
96+ Chose two commits to compare
97+ </ div >
98+ ) }
7899 { ! isMacrobenchLoading && data !== null && data . length > 0 && (
79100 < >
80101 { data . map ( ( macro , index ) => {
@@ -89,6 +110,7 @@ export default function Compare() {
89110 variant = "outline"
90111 size = "sm"
91112 className = "h-8 w-fit border-dashed mt-4 md:mt-0"
113+ disabled = { macro . result . missing_results }
92114 >
93115 < PlusCircledIcon className = "mr-2 h-4 w-4 text-primary" />
94116 < Link
@@ -99,11 +121,18 @@ export default function Compare() {
99121 </ Button >
100122 </ CardHeader >
101123 < CardContent className = "w-full p-0" >
102- < MacroBenchmarkTable
103- data = { formattedData [ index ] }
104- new = { gitRef . new }
105- old = { gitRef . old }
106- />
124+ { macro . result . missing_results ? (
125+ < div className = "text-center md:text-xl text-destructive pb-12" >
126+ Missing results for this workload
127+ </ div >
128+ ) : (
129+ < MacroBenchmarkTable
130+ data = { formattedData [ index ] }
131+ new = { gitRef . new }
132+ old = { gitRef . old }
133+ vitessRefs = { vitessRefs }
134+ />
135+ ) }
107136 </ CardContent >
108137 </ Card >
109138 </ div >
0 commit comments