Skip to content

Commit

Permalink
fix(route): reuters return fulfilled promises (#13730)
Browse files Browse the repository at this point in the history
* fix: reuters return fulfilled promises

* fix: remove deprecated routes and migration prompt
  • Loading branch information
TonyRL authored Nov 8, 2023
1 parent cc11b96 commit 9c13eb9
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 13 deletions.
3 changes: 2 additions & 1 deletion lib/v2/reuters/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = async (ctx) => {

items = items.filter((e, i) => items.findIndex((f) => e.guid === f.guid) === i);

items = await Promise.all(
const results = await Promise.allSettled(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
Expand Down Expand Up @@ -124,6 +124,7 @@ module.exports = async (ctx) => {
})
)
);
items = results.filter((r) => r.status === 'fulfilled').map((r) => r.value);

ctx.state.data = {
title,
Expand Down
2 changes: 0 additions & 2 deletions lib/v2/reuters/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module.exports = {
'/investigates': ['LyleLee'],
'/reuters/channel/:site/:channel': ['LyleLee'], // deprecated
'/reuters/theWire': ['LyleLee'], // deprecated
'/:category/:topic?': ['LyleLee', 'HenryQW', 'proletarius101', 'black-desk', 'nczitzk'],
};
3 changes: 0 additions & 3 deletions lib/v2/reuters/migration_prompt.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/v2/reuters/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module.exports = (router) => {
router.get('/channel/:site/:channel', require('./migration_prompt')); // deprecated
router.get('/theWire', require('./migration_prompt')); // deprecated
router.get('/investigates', require('./investigates'));
router.get('/:category/:topic?', require('./common'));
};
7 changes: 2 additions & 5 deletions website/docs/routes/traditional-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,12 @@ Parameters can be obtained from the official website, for instance:

## Reuters 路透社 {#reuters-lu-tou-she}

:::warning Migration notes
:::tip

1. Reuters Chinese site (`cn.reuters.com`) and British site (`uk.reuters.com`) have been terminated, redirecting to the main site (`www.reuters.com`)
2. The old routes are deprecated. Please migrate to the new routes documented below
You can use `sophi=true` query parameter to invoke the **experimental** method, which can, if possible, fetch more articles(between 20 and 100) with `limit` given. But some articles from the old method might not be available.

:::

You can use `sophi=true` query parameter to invoke the **experimental** method, which can, if possible, fetch more articles(between 20 and 100) with `limit` given. But some articles from the old method might not be available.

### Category/Topic/Author {#reuters-lu-tou-she-category-topic-author}

<Route author="HenryQW proletarius101 LyleLee nczitzk" example="/reuters/world/us" path="/reuters/:category/:topic?" paramsDesc={['find it in the URL, or tables below', 'find it in the URL, or tables below']}>
Expand Down

0 comments on commit 9c13eb9

Please sign in to comment.