Code Monkey home page Code Monkey logo

leaderboard's Introduction

#Leaderboard Service

A service that will return the statistics on which objects are the most liked
in a community. 
The service provides APIs for Like and unlike. 

Most importantly the service provides an API for that will  provide a means of querying 
for ranked list of the top K images that have received the most likes in the following time periods: 24hrs, 36hrs, 1 week, 1 month and 1 year. 

The service currently runs in Heroku:

Base URL: 
	http://imageleaderboard.herokuapp.com/api/images/ 

##Like:

Supports: POST

Expects: json with image and user.

Returns: image_id and count. HTTP 200 or 400

Format for call: api/images/like

body: {image:'imageid', user:'userid'}

Using Curl:

curl -d '{"user":"123", "image":"123"}' http://imageleaderboard.herokuapp.com/api/images/like --header "Content-Type:application/json"

##Unlike:

Unliking an Image

Supports: POST

Expects: json with image and user.

Returns: image_id and count. HTTP 200, 400 or 304 if not found

Format for call: api/images/unlike

body: {image:'imageid', user:'userid'}

Where:

  • period must be one of: '24hrs', '36hrs', 'week', 'month', 'year'
  • k must be between 0 and 100

Using Curl:

curl -d '{"user":"123", "image":"123"}' http://imageleaderboard.herokuapp.com/api/images/unlike --header "Content-Type:application/json"

##Leaderboard:

Supports: GET

API for getting the leaderboard or statistics for images Provides means for querying for a ranked list of the top K images that have received the most likes in the following time periods: last 24 hours, 36 hours, 1 week, 1 month, and 1 year.

Using Curl:

curl -G 'http://imageleaderboard.herokuapp.com/api/images/leaderboard?period=24hrs&k=10

Where:

  • period must be one of: '24hrs', '36hrs', 'week', 'month', 'year'
  • k must be between 0 and 100

response:

{ "likes": [ { "image_id": "12", "count" : 100 }, { "image_id": "1234", "count" : 12 } ] }

For more info look at leaderboard.py

Implementation notes:

In order to run this in your machine you will need to install mongodb. As this used for storage. The best way to do this is using using brew on your Mac. http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

You will also need to install flask which is the python microframework I used for implementing the REST service. The best way is to just use PIP install flask

The code includes a full set of unit Tests using Python's unittest framework. The best way to run them is using nose: Nosetests -v

leaderboard's People

Watchers

James Cloos avatar Gustavo Sandoval avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.