Skip to content

Commit

Permalink
Change expected data to be received
Browse files Browse the repository at this point in the history
  • Loading branch information
David Speers committed Jan 13, 2021
1 parent 5150f33 commit 2b9181a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lambdas/googleTrends.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ const googleTrendsAPI = require("google-trends-api");
const moment = require("moment");

exports.handler = async (event) => {
const { query, values } = JSON.parse(event.body);
const { query, userAnswer } = JSON.parse(event.body);

const dates = [
moment().subtract(366, "day").toDate(),
moment().subtract(2, "day").toDate(),
];

const cpuAnswer = await getCpuAnswer(query, dates);
values.push(cpuAnswer.replace(new RegExp(query, "ig"), ""));

const queries = values.map((value) => query + " " + value);
const answers = [userAnswer, cpuAnswer.replace(new RegExp(query, "ig"), "")];
const queries = answers.map((value) => query + " " + value);
return getTrendsScores(queries, dates);
};

Expand Down

0 comments on commit 2b9181a

Please sign in to comment.