From 46435f4f0b0097692f2f265fdbd0b737eedbb4d2 Mon Sep 17 00:00:00 2001 From: Peter O'Shaughnessy Date: Tue, 14 Nov 2017 20:53:46 +0000 Subject: [PATCH] Worked fine just not on office network :-@ Tidying up --- index.html | 30 +++++++++++++++--------------- src/template.html | 9 +++------ update.js | 17 +++++++++++------ utils.js | 6 ++++-- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/index.html b/index.html index b5a65d1..b35d2cd 100644 --- a/index.html +++ b/index.html @@ -27,32 +27,32 @@

Audience

126.8K

Dev Hub unique visitors

-

684.6% (0 days)

+

684.6% (34 days)

2.0K

Medium followers

-

11.1% (0 days)

+

11.1% (34 days)

1.2K

Twitter followers

-

8.9% (0 days)

+

8.9% (34 days)

273

Facebook followers

-

30 (0 days)

+

30 (34 days)

6.0K

Facebook reach

-

-65.0% (0 days)

+

-65.0% (34 days)

46

Instagram followers

-

7 (0 days)

+

7 (34 days)

Total social media followers: 3.5K

@@ -88,28 +88,28 @@

45.7K

Open Source (Github)

-

+

33

Repositories

-

+

183

Stars

-

+

40

Forks

Support (Github & Stack Overflow)

-

+

16

Open Issues

5

Time To Close Issues (months, avg)

-

up

+

N/A

Blogging (Medium)

@@ -125,25 +125,25 @@

SEO

WebVR

48

https://samsunginter.net/docs/webvr

-

N/A (0 days)

+

N/A (34 days)

Web Payments

13

https://samsunginter.net/docs/web-payments

-

14 (0 days)

+

14 (34 days)

Progressive Web Apps

12

https://medium.com/samsung-internet-dev/6-myths-of-progressive-web-apps-81e28ca9d2b1

-

()

+

()

Physical Web

-

()

+

()

Surveys

diff --git a/src/template.html b/src/template.html index 86780ec..9276e84 100644 --- a/src/template.html +++ b/src/template.html @@ -76,7 +76,7 @@

${facebook.engagement.views.formattedCount}

${facebook.engagement.engagements.formattedCount}

Facebook engagements (28 days)

-

${facebook.engagement.engagements.changeArrow} ${facebook.engagement.engagements.changeDirection}

+

${facebook.engagement.engagements.changeArrow} ${facebook.engagement.engagements.change}

${medium.engagement.views.formattedCount}

@@ -85,7 +85,7 @@

${medium.engagement.views.formattedCount}

Total impressions/views: ${totalImpressions}

-

Open Source (Github)

+

Open Source & Support (Github)

${github.repositories}

@@ -99,9 +99,6 @@

${github.stars}

${github.forks}

Forks

-
-

Support (Github & Stack Overflow)

-

${github.issues.openIssues}

Open Issues

@@ -109,7 +106,7 @@

${github.issues.openIssues}

${github.issues.closeTimeAvg.count}

Time To Close Issues (months, avg)

-

${github.issues.closeTimeAvg.changeDirection}

+

${github.issues.closeTimeAvg.changeArrow} ${github.issues.closeTimeAvg.change}

Blogging (Medium)

diff --git a/update.js b/update.js index 7fb3340..51be788 100644 --- a/update.js +++ b/update.js @@ -28,9 +28,16 @@ function updateStatWithChange(data, comparisonData, pathToStat, lowerIsBetter) { stat.formattedCount = utils.formatNumberValue(count); stat.change = utils.formatChangeValue(count, comparisonCount, lowerIsBetter); stat.changeLabel = comparisonDaysDiff + ' days'; - stat.changeArrow = changeDirection === 'up' ? upArrow : downArrow; stat.changeDirection = changeDirection; + stat.changeArrow = ''; + if (changeDirection === 'up') { + stat.changeArrow = upArrow; + } else if (changeDirection === 'down') { + stat.changeArrow = downArrow; + } else { + } + if (stat.link) { stat.formattedlink = utils.formatDisplayUrl(stat.link); } @@ -84,8 +91,6 @@ function processStats(stats, comparisonStats) { function updateWithGithubStats(processedStats, githubStats) { - console.log('githubStats 2', githubStats); - var totalStars = 0; var totalForks = 0; var supportRepo; @@ -114,11 +119,8 @@ function updateWithGithubStats(processedStats, githubStats) { const templateHtml = fs.readFileSync('src/template.html', 'utf8'); let processedStats = processStats(stats, comparisonStats); -console.log('Why doesnt this work...'); - fetch(GITHUB_API_REPOS_URL) .then(function(response) { - console.log('NEVER GETS HERE! WHY??!!'); return response.json(); }) .then(function(githubStats) { @@ -134,4 +136,7 @@ fetch(GITHUB_API_REPOS_URL) console.log('Updated index.html ✔'); } }); + }) + .catch(function(error) { + console.log('Error fetching Github stats', error); }); diff --git a/utils.js b/utils.js index 751314a..37c3d3e 100644 --- a/utils.js +++ b/utils.js @@ -75,14 +75,16 @@ const utils = { }, /** - * Return 'up' or 'down' string + * Return 'up', 'down' or blank string */ getChangeDirection: function(count, comparisonCount, lowerIsBetter) { if (count - comparisonCount < 0) { return lowerIsBetter ? 'up' : 'down'; - } else { + } else if (comparisonCount - count < 0) { return lowerIsBetter ? 'down' : 'up'; + } else { + return ''; } }