Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add business logic to handler #7

Merged
merged 11 commits into from
May 26, 2023
Merged

Add business logic to handler #7

merged 11 commits into from
May 26, 2023

Conversation

bryophyta
Copy link
Contributor

@bryophyta bryophyta commented May 24, 2023

What does this change?

An initial pass at implementing the business logic for the pressreader job.

  1. Take a config file that specifies a list of 'sections'.
  2. Fetch the fronts collections and CAPI backfill searches for each section.
  3. Fetch details for each article that was returned by step (2).
  4. Check the articles for eligibility:
    • Exceeds a minimum wordcount.
    • Was published in the last 24 hours.
    • Doesn't include any 'banned' tags.
    • Hasn't already been included in another section of this edition.

It then returns a list of sections and article ids, to be saved to S3 by the handler function.

How to test

  • Set a CAPI api key in resources.sh (but make sure not to commit this!)
  • Run npm run dev.
  • Output should be generated for the example config in config.ts.

How can we measure success?

This is part of migrating the existing service from on-prem to AWS Lambda.

@@ -0,0 +1,247 @@
import axios from 'axios';
Copy link
Contributor Author

@bryophyta bryophyta May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially used node's Undici fetch for all fetch calls, but kept hitting a timeout issue (perhaps related?). The timeout might just have been due to something with my connection though, so after we've tested it in other environments we might want to revert to using fetch (so as to have fewer dependencies and greater compatibility with other runtimes, e.g. Deno)

@bryophyta bryophyta marked this pull request as ready for review May 26, 2023 09:16
@bryophyta bryophyta requested a review from a team as a code owner May 26, 2023 09:16
@kenoir kenoir self-requested a review May 26, 2023 12:01
@bryophyta bryophyta merged commit 356be81 into main May 26, 2023
@bryophyta bryophyta deleted the pf/business-logic branch May 26, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants