File tree Expand file tree Collapse file tree 2 files changed +12
-18
lines changed Expand file tree Collapse file tree 2 files changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ use iron::{
17
17
use postgres:: Client ;
18
18
use router:: Router ;
19
19
use serde:: Serialize ;
20
- use serde_json:: { json, Value } ;
21
20
22
21
/// Number of release in home page
23
22
const RELEASES_IN_HOME : i64 = 15 ;
@@ -659,7 +658,9 @@ pub fn search_handler(req: &mut Request) -> IronResult<Response> {
659
658
#[ derive( Debug , Clone , PartialEq , Serialize ) ]
660
659
struct ReleaseActivity {
661
660
description : & ' static str ,
662
- activity_data : Value ,
661
+ dates : Vec < String > ,
662
+ counts : Vec < i64 > ,
663
+ failures : Vec < i64 > ,
663
664
}
664
665
665
666
impl_webpage ! {
@@ -714,13 +715,12 @@ pub fn activity_handler(req: &mut Request) -> IronResult<Response> {
714
715
715
716
ReleaseActivity {
716
717
description : "Monthly release activity" ,
717
- activity_data : json ! (
718
- {
719
- "dates" : data. iter( ) . map( |& d| d. 0 . format( "%d %b" ) . to_string( ) ) . collect:: <Vec <_>>( ) ,
720
- "counts" : data. iter( ) . map( |& d| d. 1 ) . collect:: <Vec <_>>( ) ,
721
- "failures" : data. iter( ) . map( |& d| d. 2 ) . collect:: <Vec <_>>( ) ,
722
- }
723
- ) ,
718
+ dates : data
719
+ . iter ( )
720
+ . map ( |& d| d. 0 . format ( "%d %b" ) . to_string ( ) )
721
+ . collect ( ) ,
722
+ counts : data. iter ( ) . map ( |& d| d. 1 ) . collect ( ) ,
723
+ failures : data. iter ( ) . map ( |& d| d. 2 ) . collect ( ) ,
724
724
}
725
725
. into_response ( req)
726
726
}
Original file line number Diff line number Diff line change 28
28
new Chart ( ctx , {
29
29
type : "line" ,
30
30
data : {
31
- labels : [
32
- { % if activity_data . dates - % }
33
- { % - for date in activity_data . dates - % }
34
- { { "'" ~ date ~ "'," } }
35
- { % - endfor - % }
36
- { % - endif % }
37
- ] ,
31
+ labels : { { dates | json_encode ( ) | safe } } ,
38
32
datasets : [
39
33
{
40
34
label : "Releases" ,
41
35
borderColor : "#4d76ae" ,
42
36
backgroundColor : "#4d76ae" ,
43
37
fill : false ,
44
- data : [ { { activity_data . counts | default ( value = [ ] ) | join ( sep = ", " ) } } ] ,
38
+ data : { { counts | json_encode ( ) | safe } } ,
45
39
} ,
46
40
{
47
41
label : "Build Failures" ,
48
42
borderColor : "#434348" ,
49
43
backgroundColor : "#434348" ,
50
44
fill : false ,
51
- data : [ { { activity_data . failures | default ( value = [ ] ) | join ( sep = ", " ) } } ] ,
45
+ data : { { failures | json_encode ( ) | safe } } ,
52
46
} ,
53
47
]
54
48
} ,
You can’t perform that action at this time.
0 commit comments