Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Update ganache, remove stars, hopefully fix canvas growth bug, and change stats comparison #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/javascripts/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import ReactDOM from "react-dom";
//import Footer from "./footer.jsx";

import DownloadsTile from "./tiles/downloads.jsx";
import StargazersTile from "./tiles/stargazers.jsx";
import TotalDownloadsTile from "./tiles/totaldownloads.jsx";
// import StargazersTile from "./tiles/stargazers.jsx";
// import TotalDownloadsTile from "./tiles/totaldownloads.jsx";

var Dashboard = React.createClass({
render: function() {
return (
<div className="dashboard">
<div className="section">
<div className="container">
<div className="dashboard-container">
davidmurdoch marked this conversation as resolved.
Show resolved Hide resolved
<h1 className="mb-6">Dashboard</h1>

<h2>Downloads</h2>
Expand All @@ -30,10 +30,10 @@ var Dashboard = React.createClass({
</div>
</div>

<h3>GANACHE (ganache-cli)</h3>
<h3>GANACHE</h3>
<div className="tile is-ancestor">
<div className="tile is-12">
<DownloadsTile colorclassName="is-ganache" packageName="ganache-cli" startDate="2017-10-01" />
<DownloadsTile colorclassName="is-ganache" packageName="ethereumjs-testrpc,ganache,ganache-cli,ganache-core" startDate="2016-01-08" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add all ganache packages and changes the date to include the first testrpc downloads

</div>
</div>

Expand All @@ -43,7 +43,7 @@ var Dashboard = React.createClass({
<DownloadsTile colorclassName="is-drizzle" packageName="drizzle" startDate="2017-12-01" />
</div>
</div>

{/*
<h2 className="mt-5">Developer Adoption</h2>
<p>
Truffle Suite's usage by developers over time, measured in GitHub stars.
Expand All @@ -53,7 +53,7 @@ var Dashboard = React.createClass({
<StargazersTile projects={["trufflesuite/truffle", "trufflesuite/ganache", "trufflesuite/drizzle"]}/>
</div>
</div>

*/}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stargazers didn't work

</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/javascripts/footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Footer = React.createClass({
render: function() {
return (
<footer className="footer">
<div className="container">
<div className="dashboard-container">
<div className="content has-text-centered">
<p>
Made with &#x02764; across the USA.
Expand Down
2 changes: 1 addition & 1 deletion app/javascripts/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
var Header = React.createClass({
render: function() {
return (
<div className="container">
<div className="dashboard-container">
<nav className="nav">
<div className="nav-left">
<a className="nav-item no-left-padding">
Expand Down
50 changes: 37 additions & 13 deletions app/javascripts/tiles/downloads.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,38 @@ var DownloadsTile = React.createClass({
requests = requests.map(function(months) {
var start = months[0];
var end = months[1];
return "https://api.npmjs.org/downloads/range/" + start.format("YYYY-MM-DD") + ":" + end.format("YYYY-MM-DD") + "/" + self.props.packageName;
const names = self.props.packageName.split(",");
return names.map(name => {
return "https://api.npmjs.org/downloads/range/" + start.format("YYYY-MM-DD") + ":" + end.format("YYYY-MM-DD") + "/" + name;
});
});

reduce(requests, [], function(memo, item, callback) {
axios.get(item).then(function(response) {
var downloads = response.data.downloads;
callback(null, memo.concat(downloads));
}).catch(callback)
}, function(err, downloads) {
function getDownloads(memo, items, callback) {
const responses = items.map(item => axios.get(item));
Promise.all(responses)
.then(results => {
results.forEach(response => {
response.data.downloads.forEach(download => {
const existing = memo.find(item => item.day === download.day);
if (existing) {
existing.downloads += download.downloads;
} else {
memo.push(download);
}
});
});
callback(null, memo);
})
.catch(error => {
console.error(error);
callback(error);
});
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes it so each "Tile" can specify multiple comma-separated packages. This code downloads the stats for all packages for the Tile and combines them together.


reduce(requests, [], function(memo, items, callback) {
getDownloads(memo, items, callback);
}, function(err, downloads) {
downloads.sort((a, b) => a.day.localeCompare(b.day));
var total = 0;
var showCurrent = window.location.search.toLowerCase().indexOf("current") >= 0;
var data = {
Expand Down Expand Up @@ -160,11 +182,11 @@ var DownloadsTile = React.createClass({
actualdataset.push(null);
}

var lastThreeMonths = (maindataset[maindataset.length - 1] + maindataset[maindataset.length - 2] + maindataset[maindataset.length - 3]);
var prevThreeMonths = (maindataset[maindataset.length - 4] + maindataset[maindataset.length - 5] + maindataset[maindataset.length - 6]);
var lastSixMonths = (maindataset[maindataset.length - 1] + maindataset[maindataset.length - 2] + maindataset[maindataset.length - 3] + maindataset[maindataset.length - 4] + maindataset[maindataset.length - 5] + maindataset[maindataset.length - 6]);
var prevSixMonths = (maindataset[maindataset.length - 7] + maindataset[maindataset.length - 8] + maindataset[maindataset.length - 9] - maindataset[maindataset.length - 10] + maindataset[maindataset.length - 11] + maindataset[maindataset.length - 12]);

var totalGrowthInDownloads = lastThreeMonths - prevThreeMonths;
var growth = Math.round(Math.abs(totalGrowthInDownloads) / prevThreeMonths * 100);
var totalGrowthInDownloads = lastSixMonths - prevSixMonths;
var growth = Math.round(Math.abs(totalGrowthInDownloads) / prevSixMonths * 100);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a lot more data than we used to, and six months will show a consistently more favorable picture, given the ebbs and flows of crypto dev

var direction = totalGrowthInDownloads < 0 ? "down" : "up";

self.setState({
Expand Down Expand Up @@ -363,7 +385,7 @@ var DownloadsTile = React.createClass({
const GrowthTile = this.state.growth ? (
<div className={'tile is-child notification has-border descriptive-tile ' + this.props.colorclassName}>
<div>
Last Three Months
Last Six Months
</div>
<div className="content is-large is-marginless">
<h1 className="white is-marginless">{this.state.growth_direction} {this.state.growth}%</h1>
Expand All @@ -378,7 +400,9 @@ var DownloadsTile = React.createClass({
<div className="tile">
<div className="tile is-parent is-8">
<div className={'tile is-child notification ' + this.props.colorclassName}>
{chart}
<div>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this extra div container will prevent the infinite growth bug. weird but maybe worth a shot!

{chart}
</div>
</div>
</div>
<div className="tile is-vertical is-parent">
Expand Down
2 changes: 1 addition & 1 deletion app/stylesheets/dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
}

> .container {
> .dashboard-container {
border-bottom: 2px solid #5e464d;
max-width: 100%;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@
.dashboard .section h1, .dashboard .section h2, .dashboard .section h3, .dashboard .section h4, .dashboard .section h5, .dashboard .section h6 {
color: #fff;
font-weight: 400; }
.dashboard > .container {
.dashboard > .dashboard-container {
border-bottom: 2px solid #5e464d;
max-width: 100%; }
.dashboard .notification {
Expand Down
Loading