Skip to content

Instantly share code, notes, and snippets.

@doapp-jeremy
Created April 3, 2015 14:15
Show Gist options
  • Save doapp-jeremy/20552c85375bcd579e6f to your computer and use it in GitHub Desktop.
Save doapp-jeremy/20552c85375bcd579e6f to your computer and use it in GitHub Desktop.
lambda
var Tags = require('../tags.js');
var handler = function (record, context) {
if (record.tagUuid) {
console.log(record.tagUuid);
Tags.getLastItemsObject(record.tagUuid).then(function (result) {
var result = {
"metrics": {"milliseconds": "852"},
"lastKey": {
"tagUuid": "tag-1",
"pubDate": "2015-03-10T19:43:50+00:00",
"itemUuid": "9b534141-7d55-f52a-26c7-19bf86e4a1fc"
},
"branding": {"backgroundColor": "#B60E0E", "foregroundColor": "#FFFFFF", "style": "cards"},
"content": [{
"uuid": "9b534141-c6ab-919f-aae7-ef69440ddba1",
"type": "article_summary",
"click": {"action": "push", "destination": "hybrid_article"},
"display": {
"uuid": "9b534141-c6ab-919f-aae7-ef69440ddba1",
"revision": "1",
"title": "Troop Returns Home From Deployment",
"image": "find image",
"link": "http://www.KAALtv.com/article/stories/s3729586.shtml?cat=10151",
"pubDateOriginal": "Tue Mar 10 2015 03:46:19 GMT+0000 (UTC)",
"author": "",
"summary": "create summary",
"source": "http://www.kaaltv.com/rssFeeds/rssLong10151.xml",
"hash": "26757c7c27cf717b5e0db109c8f07f8e",
"path": "site-1/9b534141/c6ab/919f/aae7/ef69440ddba1/items/9b534141-c6ab-919f-aae7-ef69440ddba1/1.json"
}
}, {
"uuid": "9b534141-e592-ba2c-1c91-1ff1198c010c",
"type": "article_summary",
"click": {"action": "push", "destination": "hybrid_article"},
"display": {
"uuid": "9b534141-e592-ba2c-1c91-1ff1198c010c",
"revision": "1",
"title": "FCA Banquet Honors Champions",
"image": "find image",
"link": "http://www.KAALtv.com/article/stories/s3729592.shtml?cat=10151",
"pubDateOriginal": "Tue Mar 10 2015 03:54:25 GMT+0000 (UTC)",
"author": "",
"summary": "create summary",
"source": "http://www.kaaltv.com/rssFeeds/rssLong10151.xml",
"hash": "e70b96cab6d490bda0653cb008c1d6ed",
"path": "site-1/9b534141/e592/ba2c/1c91/1ff1198c010c/items/9b534141-e592-ba2c-1c91-1ff1198c010c/1.json"
}
}, {
"uuid": "9b534141-ef34-2bb7-7fee-c46c95f91b67",
"type": "article_summary",
"click": {"action": "push", "destination": "hybrid_article"},
"display": {
"uuid": "9b534141-ef34-2bb7-7fee-c46c95f91b67",
"revision": "1",
"title": "Legislators Look at Tougher Requirements to Protect Habitat",
"image": "find image",
"link": "http://www.KAALtv.com/article/stories/s3730100.shtml?cat=10151",
"pubDateOriginal": "Tue Mar 10 2015 16:01:48 GMT+0000 (UTC)",
"author": "",
"summary": "create summary",
"source": "http://www.kaaltv.com/rssFeeds/rssLong10151.xml",
"hash": "e007997758732b22bc101dfb73720279",
"path": "site-1/9b534141/ef34/2bb7/7fee/c46c95f91b67/items/9b534141-ef34-2bb7-7fee-c46c95f91b67/1.json"
}
}, {
"uuid": "9b534141-6fbd-7769-7372-eb59504caa53",
"type": "article_summary",
"click": {"action": "push", "destination": "hybrid_article"},
"display": {
"uuid": "9b534141-6fbd-7769-7372-eb59504caa53",
"revision": "1",
"title": "Thick Ice Slows Start of Shipping on Upper Mississippi River ",
"image": "find image",
"link": "http://www.KAALtv.com/article/stories/s3729869.shtml?cat=10151",
"pubDateOriginal": "Tue Mar 10 2015 14:04:03 GMT+0000 (UTC)",
"author": "",
"summary": "create summary",
"source": "http://www.kaaltv.com/rssFeeds/rssLong10151.xml",
"hash": "32392ae290f218175728d29b2eee44a6",
"path": "site-1/9b534141/6fbd/7769/7372/eb59504caa53/items/9b534141-6fbd-7769-7372-eb59504caa53/1.json"
}
}, {
"uuid": "9b534141-7d55-f52a-26c7-19bf86e4a1fc",
"type": "article_summary",
"click": {"action": "push", "destination": "hybrid_article"},
"display": {
"uuid": "9b534141-7d55-f52a-26c7-19bf86e4a1fc",
"revision": "1",
"title": "Legendary Volleyball Coach Suspended",
"image": "find image",
"link": "http://www.KAALtv.com/article/stories/s3729584.shtml?cat=10151",
"pubDateOriginal": "Tue Mar 10 2015 03:44:03 GMT+0000 (UTC)",
"author": "",
"summary": "create summary",
"source": "http://www.kaaltv.com/rssFeeds/rssLong10151.xml",
"hash": "a239d1b1c66275cb98013bfc82ee46f6",
"path": "site-1/9b534141/7d55/f52a/26c7/19bf86e4a1fc/items/9b534141-7d55-f52a-26c7-19bf86e4a1fc/1.json"
}
}]
};
context.done(null, result);
}).fail(function (err) {
context.done('Error getting items for tag : ' + err, err);
});
} else {
console.log(record);
context.done(null, {'error': 'no tag uuid'});
}
};
exports.handler = handler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment