Created
April 25, 2020 08:46
-
-
Save digitalbase/f39caeeae826cf83b34e9489e55a5352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /src/handlers/api/getUser.js | |
const { withStatusCode } = require('../../utils/response.util'); | |
const dynamoDBFactory = require('../../dynamodb.factory'); | |
const { UserToAnonymousModel } = require('../../models/UserToAnonymous'); | |
const { SourceAttributionModel } = require('../../models/SourceAttribution'); | |
const dynamoDb = dynamoDBFactory(); | |
const model_usermap = new UserToAnonymousModel(dynamoDb); | |
const model_source = new SourceAttributionModel(dynamoDb); | |
const ok = withStatusCode(200, JSON.stringify); | |
exports.handler = async (event) => { | |
const { id } = event.pathParameters; | |
const anonymousIds = await model_usermap.getAnonymousIdsForUser(id); | |
// get all things from sessions with those anonymousId | |
const attributionSessions = await model_source.getForAnonymousIds(anonymousIds); | |
return ok({ | |
anonymousIds : anonymousIds, | |
sessions: attributionSessions | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment