feat: add linux patchwork comments (#1327)

This commit is contained in:
Richard Yu
2018-12-31 01:02:50 +08:00
committed by DIYgod
parent a94c087f53
commit 76103963aa
4 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
const axios = require('../../utils/axios');
module.exports = {
getPatchnameFromID: async (ctx, id) => {
const key = 'patchwork-kernel-org-patchname-from-id-' + id;
let name = await ctx.cache.get(key);
if (!name) {
const patchDetail = await axios({
method: 'get',
url: `https://patchwork.kernel.org/api/patches/${id}/`,
});
name = patchDetail.data.name;
ctx.cache.set(key, name, 24 * 60 * 60);
}
return name;
},
};