Fixed GitHub feed

This commit is contained in:
ポール ウェッブ 2018-07-30 16:39:32 -05:00
parent 6aa929711c
commit d283a31128
2 changed files with 28 additions and 1 deletions

View file

@ -4,6 +4,7 @@
// P A C K A G E S
const async = require("async");
const color = require("turbocolor");
const cors = require("cors");
const dedent = require("dedent");
@ -298,7 +299,7 @@ function generateGitHubFeed(displayGitHubFeed) {
`);
}
// TODO: Update `.last-updated` every minute
updateGithubFeed(); // TODO: Update `.last-updated` every minute
displayGitHubFeed(dedent`
<h3>GitHub</h3>
@ -377,6 +378,29 @@ function newsletterSubscribe(data, socket) {
});
}
function updateGithubFeed() {
octokit.activity.getEventsForOrg({
org: "lbryio",
per_page: 20,
page: 1
}).then(({ data }) => {
async.eachSeries(data, (item, callback) => {
const eventString = JSON.stringify(item);
client.zrank("events", eventString, (err, reply) => {
if (reply === null) client.zadd("events", item.id, eventString, callback);
else callback();
});
}, () => client.zremrangebyrank("events", 0, -51)); // Keep the latest 50 events
}).catch(err => {
logSlackError(
"\n" +
"> *GITHUB FEED ERROR:* ```" + JSON.parse(JSON.stringify(err)) + "```" + "\n" +
"> _Cause: GitHub feed refresh_\n"
);
});
}
function uploadImage(imageSource) {
return new Promise((resolve, reject) => {
request({

View file

@ -1,2 +1,5 @@
// https://github.com/lbryio/lbry/blob/master/docs/api.json
// https://rawgit.com/lbryio/lbry/master/docs/api.json
// https://cdn.rawgit.com/lbryio/lbry/5b3103e4/docs/api.json
// https://www.npmjs.com/package/make-fetch-happen