I have an API for which I created a lambda function to hit it on the 1st of every month.
All the steps executed upon hitting the API:
NOTE: Each user needs to get a single gift card only. Another related thread by me.
Currently In my lamda I used a loop to hit the API(every time gift cards will be sent to only first 100 users and in the next time same query is run those users will not be returned by the query).
Since number of users can be very large I want to make concurrent requests so that lambda doesn't time out.
Query to fetch users:
? will be replaced with the current year and month
SELECT u.id, u.first_name, u.last_name, u.email, u.date_of_birth
FROM user u
LEFT JOIN gift_card gc ON
DATE_FORMAT(gc.scheduled_at, '%Y') = ? AND
gc.message = 'Happy birthday! from BURST' AND
gc.status = 1 AND
gc.recipient_email = u.email
WHERE
DATE_FORMAT(u.date_of_birth, '%m') = ? AND
u.email IS NOT NULL AND u.status = 10 AND
gc.recipient_email IS NULL
LIMIT 100
After this I run another query to add gift card in gift table and then send the mail.
Is there any way to achieve this in node? maybe a different service or by using some other technique.