Files

17 lines
519 B
JavaScript
Raw Permalink Normal View History

2019-06-03 18:03:05 +08:00
const got = require('@/utils/got');
2018-12-31 01:02:50 +08:00
module.exports = {
getPatchnameFromID: async (ctx, id) => {
const key = 'patchwork-kernel-org-patchname-from-id-' + id;
let name = await ctx.cache.get(key);
if (!name) {
2019-06-03 18:03:05 +08:00
const patchDetail = await got({
2018-12-31 01:02:50 +08:00
method: 'get',
url: `https://patchwork.kernel.org/api/patches/${id}/`,
});
name = patchDetail.data.name;
2019-05-09 01:23:29 +08:00
ctx.cache.set(key, name);
2018-12-31 01:02:50 +08:00
}
return name;
},
};