Challenge Overview

Challenge Objectives

 

  • Update member stats endpoints in Member Service

 

Project Background

  • Topcoder Member service is a service that manages a lot of member related data - user profile, traits, stats, search etc

  • In this challenge we want to update how member statistics is handled

  • Future challenges will implement data loading and frontend changes in our community app

 

Technology Stack

 

  • Java

  • Maven

  • DynamoDB

  • Elasticsearch

 

Code access

 

The base code is available in Github repo. Use dev branch as base. Sample database structure for the new DynamoDB table is posted in the forums.

 

Individual requirements

 

At the moment, member statistics are calculated for each user and persisted into a DynamoDB table. However, members can be in multiple “groups” and we want to store member statistics for each group separately.

On a data storage level, the change will be simple - creating a table with a composite primary key - (userId, groupId).

On API level, this will include two things:

  • Adding another parameter to the member stats endpoint to filter the results by groupId.

  • Handling authorization - user that is calling the API has to have access to the same groupId :

    • Group is public (topcoder group) - identified by a fixed groupId (make this configurable) or

    • user is either trying to read his stats, is a member of the group, is admin, or is calling with a machine token that has “read:user_profiles” scope). To get a list of groups the current user is a member of, call GET API_BASE/v3/groups?memberId=:userId&membershipType=user with the caller user token

    • Member stats api endpoint should first try to load the record from ES and if there isn’t such record, load it from DynamoDB as a fallback (NOTE: we don’t have such ES index yet - create a sample index for verification)

Example from Member Profile:

https://github.com/appirio-tech/ap-member-microservice/blob/ae617c62bd6b79a570c5e97f00ebf6fa3db4eae9/service/src/main/java/com/appirio/service/member/manager/MemberProfileManager.java#L222

 

Current member stats endpoint is GET /v3/members/:handle/stats and the new endpoint will map to GET /v3/members/:handle/stats?:groupIds (groupId is optional - if it’s not provided, return stats for the default Topcoder group, otherwise return stats for each of the groupIds in the list).

 

Getting started notes

Take a look at the following files - most of the changes will be there:

 

General requirements

 

  • Unit tests are in scope.

  • All configuration parameters should be extracted to a common settings module. Sensitive configuration parameters should be set from environment variables (DB URL, AWS credentials, etc).

  • Logging is required for all service calls - follow the current codebase

  • Update Postman collection and Swagger spec

 

What To Submit

 

  • All source code as a git patch

  • Verification guide

  • Winner will be required to create a pull request



Final Submission Guidelines

See above

ELIGIBLE EVENTS:

Topcoder Open 2019

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30091597