@@ -3,12 +3,57 @@ use std::collections::HashMap;
33use std:: sync:: Arc ;
44
55use crate :: api:: graphs:: GraphKind ;
6- use crate :: api:: { graphs, ServerResult } ;
6+ use crate :: api:: { detail , graphs, ServerResult } ;
77use crate :: db:: { self , ArtifactId , Profile , Scenario } ;
88use crate :: interpolate:: IsInterpolated ;
99use crate :: load:: SiteCtxt ;
1010use crate :: selector:: { CompileBenchmarkQuery , CompileTestCase , Selector , SeriesResponse } ;
1111
12+ /// Returns data for a detailed information when comparing a single test result comparison
13+ /// for a compile-time benchmark.
14+ pub async fn handle_compile_detail (
15+ request : detail:: Request ,
16+ ctxt : Arc < SiteCtxt > ,
17+ ) -> ServerResult < detail:: Response > {
18+ log:: info!( "handle_compile_detail({:?})" , request) ;
19+
20+ let artifact_ids = Arc :: new ( master_artifact_ids_for_range (
21+ & ctxt,
22+ request. start ,
23+ request. end ,
24+ ) ) ;
25+
26+ let interpolated_responses: Vec < _ > = ctxt
27+ . statistic_series (
28+ CompileBenchmarkQuery :: default ( )
29+ . benchmark ( Selector :: One ( request. benchmark ) )
30+ . profile ( Selector :: One ( request. profile . parse ( ) ?) )
31+ . scenario ( Selector :: One ( request. scenario . parse ( ) ?) )
32+ . metric ( Selector :: One ( request. stat . parse ( ) ?) ) ,
33+ artifact_ids. clone ( ) ,
34+ )
35+ . await ?
36+ . into_iter ( )
37+ . map ( |sr| sr. interpolate ( ) . map ( |series| series. collect :: < Vec < _ > > ( ) ) )
38+ . collect ( ) ;
39+
40+ let mut graphs = Vec :: new ( ) ;
41+
42+ let mut interpolated_responses = interpolated_responses. into_iter ( ) ;
43+ if let Some ( response) = interpolated_responses. next ( ) {
44+ let series = response. series . into_iter ( ) . collect :: < Vec < _ > > ( ) ;
45+ for kind in request. kinds {
46+ graphs. push ( graph_series ( series. clone ( ) . into_iter ( ) , kind) ) ;
47+ }
48+ }
49+ assert ! ( interpolated_responses. next( ) . is_none( ) ) ;
50+
51+ Ok ( detail:: Response {
52+ commits : artifact_ids_to_commits ( artifact_ids) ,
53+ graphs,
54+ } )
55+ }
56+
1257pub async fn handle_graphs (
1358 request : graphs:: Request ,
1459 ctxt : Arc < SiteCtxt > ,
@@ -33,7 +78,7 @@ pub async fn handle_graphs(
3378 }
3479 }
3580
36- let resp = create_graphs ( request, & ctxt) . await ?;
81+ let resp = Arc :: new ( create_graphs ( request, & ctxt) . await ?) ;
3782
3883 if is_default_query {
3984 ctxt. landing_page . store ( Arc :: new ( Some ( resp. clone ( ) ) ) ) ;
@@ -45,7 +90,7 @@ pub async fn handle_graphs(
4590async fn create_graphs (
4691 request : graphs:: Request ,
4792 ctxt : & SiteCtxt ,
48- ) -> ServerResult < Arc < graphs:: Response > > {
93+ ) -> ServerResult < graphs:: Response > {
4994 let artifact_ids = Arc :: new ( master_artifact_ids_for_range (
5095 ctxt,
5196 request. start ,
@@ -98,17 +143,21 @@ async fn create_graphs(
98143 . insert ( scenario, graph_series) ;
99144 }
100145
101- Ok ( Arc :: new ( graphs:: Response {
102- commits : Arc :: try_unwrap ( artifact_ids)
103- . unwrap ( )
104- . into_iter ( )
105- . map ( |c| match c {
106- ArtifactId :: Commit ( c) => ( c. date . 0 . timestamp ( ) , c. sha ) ,
107- ArtifactId :: Tag ( _) => unreachable ! ( ) ,
108- } )
109- . collect ( ) ,
146+ Ok ( graphs:: Response {
147+ commits : artifact_ids_to_commits ( artifact_ids) ,
110148 benchmarks,
111- } ) )
149+ } )
150+ }
151+
152+ fn artifact_ids_to_commits ( artifact_ids : Arc < Vec < ArtifactId > > ) -> Vec < ( i64 , String ) > {
153+ Arc :: try_unwrap ( artifact_ids)
154+ . unwrap ( )
155+ . into_iter ( )
156+ . map ( |c| match c {
157+ ArtifactId :: Commit ( c) => ( c. date . 0 . timestamp ( ) , c. sha ) ,
158+ ArtifactId :: Tag ( _) => unreachable ! ( ) ,
159+ } )
160+ . collect ( )
112161}
113162
114163/// Returns master commit artifact IDs for the given range.
0 commit comments