@@ -34,19 +34,29 @@ object Plot {
3434 }
3535 }
3636
37- def csvToBars (dir : File , allowedVersion : String => Boolean , filterOutMonths : Set [YearMonth ] = Set ()): Seq [Trace ] = {
37+ def csvToBars (
38+ dir : File ,
39+ allowedVersion : String => Boolean ,
40+ filterOutMonths : Set [YearMonth ] = Set ()
41+ ): Seq [Trace ] = {
3842
3943 val data = for {
4044 year <- 2015 to Year .now(ZoneOffset .UTC ).getValue
4145 month <- 1 to 12
4246 f = new File (dir, f " $year/ $month%02d.csv " )
4347 if f.exists()
4448 ym = YearMonth .of(year, month)
45- elem <- CSVReader .open(f)
49+ elem <- CSVReader
50+ .open(f)
4651 .iterator
4752 .map(l => (ym, /* version */ l(0 ), /* downloads */ l(1 ).toInt))
48- .collect { case (date, version @ relevantVersion(major, minor, patch), downloads) if allowedVersion(version) =>
49- (date, (major, minor, patch), downloads)
53+ .collect {
54+ case (
55+ date,
56+ version @ relevantVersion(major, minor, patch),
57+ downloads
58+ ) if allowedVersion(version) =>
59+ (date, (major, minor, patch), downloads)
5060 }
5161 .toVector
5262 } yield elem
@@ -76,30 +86,44 @@ object Plot {
7686 for {
7787 artifact <- stats.Params .artifacts
7888 (baseDir, divId, title) <- Seq (
79- (" per-version-stats" , s " ${artifact}-total " , s " ${artifact} (total downloads) " ),
80- (" per-version-unique-ips" , s " ${artifact}-unique " , s " ${artifact} (unique IPs) " )
89+ (
90+ " per-version-stats" ,
91+ s " ${artifact}-total " ,
92+ s " ${artifact} (total downloads) "
93+ ),
94+ (
95+ " per-version-unique-ips" ,
96+ s " ${artifact}-unique " ,
97+ s " ${artifact} (unique IPs) "
98+ )
8199 )
82- bars = csvToBars(dataBase.resolve(baseDir).resolve(artifact).toFile, _ => true /* keep all the versions */ )
83- } yield
84- s """
85- |<h2 id=" ${divId}-plot"> ${title} <a href="# ${divId}-plot">#</a></h2>
86- |<div id=" ${divId}"></div>
87- |<script> ${Plotly .jsSnippet(divId, bars, Layout (barmode = BarMode .Stack ))}</script>
88- | """ .stripMargin
100+ bars = csvToBars(
101+ dataBase.resolve(baseDir).resolve(artifact).toFile,
102+ _ => true /* keep all the versions */
103+ )
104+ } yield s """
105+ |<h2 id=" ${divId}-plot"> ${title} <a href="# ${divId}-plot">#</a></h2>
106+ |<div id=" ${divId}"></div>
107+ |<script> ${Plotly .jsSnippet(
108+ divId,
109+ bars,
110+ Layout (barmode = BarMode .Stack )
111+ )}</script>
112+ | """ .stripMargin
89113
90114 val html =
91115 s """ <!DOCTYPE html>
92- |<html>
93- |<head>
94- |<title>Scalafix Statistics</title>
95- |<script src="https://cdn.plot.ly/plotly- ${Plotly .plotlyVersion}.min.js"></script>
96- |</head>
97- |<body>
98- |<h1>Scalafix Statistics</h1>
99- | ${htmlSnippets.mkString}
100- |</body>
101- |</html>
102- | """ .stripMargin
116+ |<html>
117+ |<head>
118+ |<title>Scalafix Statistics</title>
119+ |<script src="https://cdn.plot.ly/plotly- ${Plotly .plotlyVersion}.min.js"></script>
120+ |</head>
121+ |<body>
122+ |<h1>Scalafix Statistics</h1>
123+ | ${htmlSnippets.mkString}
124+ |</body>
125+ |</html>
126+ | """ .stripMargin
103127
104128 Files .createDirectories(dataBase)
105129 Files .write(dataBase.resolve(" index.html" ), html.getBytes(" UTF-8" ))
0 commit comments