Skip to content
This repository has been archived by the owner on Apr 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #465 from apoclyps/farset-labs-calendar-lambda-cor…
Browse files Browse the repository at this point in the history
…rections

Update Farset Labs calendar lambda for fixes and readme updates
  • Loading branch information
alistairjcbrown authored Oct 14, 2018
2 parents 5df534c + bfe6139 commit 8c795d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lambdas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ changes

### Producer

This lambda pulls data from the Farset Labs calendar iCalendar endpoint and
This lambda pulls data from the Farset Labs Google calendar JSON endpoint and
saves it to S3.

You will need to create a new entry in the AWS Systems Manager Parameter store
Expand All @@ -206,7 +206,7 @@ functionality of the lambda.
#### `farsetlabs:producer:invoke`

Invoke the lambda on AWS. As this lambda creates files in S3, you should see new
ICS files created with the data pulled from the Farset Labs calendar.
JSON files created with the data pulled from the Farset Labs calendar.

#### `farsetlabs:producer:invoke-local`

Expand All @@ -228,7 +228,7 @@ Pulls the logs from cloudwatch of the last lambda run. Useful for debugging.

### Transformer

This lambda takes the Farset Labs calendar iCalendar data which has been
This lambda takes the Farset Labs Google calendar JSON data which has been
saved to S3, transforms it into a standardised format and saves it back to S3.

This lambda is triggered by the creation of the source file by the producer
Expand Down
2 changes: 1 addition & 1 deletion lambdas/farsetlabs/handlers/producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports.produce = async (event, context, callback) => {
const { producerBucket } = buckets();
const filePath = (await uploadData(producerBucket, calendarData)).key;

callback(null, { message: filePath });
callback(null, { message: [filePath] });
} catch (err) {
callback(err, null);
}
Expand Down
11 changes: 10 additions & 1 deletion lambdas/farsetlabs/handlers/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { getFromS3 } = require("aws-lambda-data-utils");
const { validate } = require("jsonschema");
const eventSchema = require("./schemas/event-schema");
const { buckets } = require("../config");
const { uploadData } = require("../utils");
const { uploadTo } = require("../utils");

const transformEvent = function (defaults, {
id, summary, description, start, end, created, updated
Expand Down Expand Up @@ -47,6 +47,15 @@ const transformEvent = function (defaults, {

const isValidEvent = (event) => validate(event, eventSchema).errors.length === 0;

const uploadData = function(bucketName, calendarData) {
return uploadTo(
bucketName,
(today, hash) =>
`farset-labs-calendar__${today.valueOf()}__${hash}.json`,
calendarData
);
};

module.exports.transform = async (event, context, callback) => {
try {
const records = event.Records;
Expand Down

0 comments on commit 8c795d6

Please sign in to comment.