From 905d8ffe4417f15b43f74c736a3eab1b8d42124a Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 8 Jul 2019 23:26:59 +0800 Subject: [PATCH] fix: remove redundant promise --- lib/routes/google/scholar.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/routes/google/scholar.js b/lib/routes/google/scholar.js index d6938e645..f8a1413a1 100644 --- a/lib/routes/google/scholar.js +++ b/lib/routes/google/scholar.js @@ -24,25 +24,18 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const list = $('#gs_res_ccl_mid .gs_r.gs_or.gs_scl .gs_ri').get(); - const out = await Promise.all( - list.map(async (item) => { - const $ = cheerio.load(item); - const itemUrl = $('h3 a').attr('href'); - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const single = { - title: $('h3 a').text(), - author: $('.gs_a').text(), - description: $('.gs_rs').text(), - link: itemUrl, - guid: itemUrl, - }; + const out = list.map((item) => { + const $ = cheerio.load(item); + const itemUrl = $('h3 a').attr('href'); + return { + title: $('h3 a').text(), + author: $('.gs_a').text(), + description: $('.gs_rs').text(), + link: itemUrl, + guid: itemUrl, + }; + }); - return Promise.resolve(single); - }) - ); ctx.state.data = { title: `Google Scholar Monitor: ${query}`, link: url,