diff --git a/index.js b/index.js index d00ab23..e106023 100644 --- a/index.js +++ b/index.js @@ -215,6 +215,7 @@ app.get('/stats', (request, response) => { var viewCounts = new Array(); var deletionCounts = new Array(); var submissionCounts = new Array(); + var shareCounts = new Array(); var boostCounts = new Array(); var dayLabels = new Array(); @@ -240,17 +241,24 @@ app.get('/stats', (request, response) => { && d.isSame(l.date, 'day') }).length ); + shareCounts.push( + logs.filter((l) => { + return l.event_type === "share" + //&& l.date < moment().subtract(1, 'hour') + && d.isSame(l.date, 'day') + }).length + ); deletionCounts.push( logs.filter((l) => { return l.event_type === "delete" - && l.date < moment().subtract(1, 'hour') + //&& l.date < moment().subtract(1, 'hour') && d.isSame(l.date, 'day') }).length ); submissionCounts.push( logs.filter((l) => { return l.event_type === "submit" - && l.date < moment().subtract(1, 'hour') + //&& l.date < moment().subtract(1, 'hour') && d.isSame(l.date, 'day') }).length ); @@ -274,7 +282,8 @@ app.get('/stats', (request, response) => { "views": viewCounts, "submissions": submissionCounts, "boosts": boostCounts, - "deletions": deletionCounts + "deletions": deletionCounts, + "shares": shareCounts } }); @@ -441,7 +450,13 @@ app.get("/:accountURL", (request, response, next) => { response.redirect("/"); } else { database.update("accounts", {url: request.params.accountURL}, {boostPoints: results[0].boostPoints + 2}, (updated) => { - response.redirect("/"); + database.insert("logs", [{ + event_type: "share", + code: results[0].code, + date: new Date() + }], (results) => { + response.redirect("/"); + }, (error) => {}); }, (error) => {}); } } diff --git a/views/account.hbs b/views/account.hbs index 078ac53..e6bd324 100644 --- a/views/account.hbs +++ b/views/account.hbs @@ -74,7 +74,8 @@ by giving them this custom link. When they use it, your code will rank higher to all visitors.
- https://pmreferrals.ca/{{account.url}} + https://pmreferrals.ca/{{account.url}}
+ Tweet
diff --git a/views/stats.hbs b/views/stats.hbs index e4c369c..0c41318 100644 --- a/views/stats.hbs +++ b/views/stats.hbs @@ -47,6 +47,10 @@ name: 'Boosts', data: [{{#each chartData.boosts}}{{this}},{{/each}}] }, + { + name: 'Shares', + data: [{{#each chartData.shares}}{{this}},{{/each}}] + }, { name: 'Submissions', data: [{{#each chartData.submissions}}{{this}},{{/each}}] @@ -56,7 +60,7 @@ data: [{{#each chartData.deletions}}{{this}},{{/each}}] }, ], - colors: ['#034045', '#daa520', '#00ff00', '#850101'], + colors: ['#034045', '#daa520', '#add8e6', '#00ff00', '#850101'], xaxis: { type: "datetime", categories: [{{#each chartData.labels}}"{{this}}",{{/each}}],