Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
models
spec
Gemfile
Gemfile.lock
README
Rakefile
chat.rb

README

I chose to implement the problem as an API.

-- Solution Method

- I created the dataset in memory.  But I assume the data is stored in a document database (riak, mongo, etc). 
I chose to store the data in a document database to ensure scalability of the all the chats through time.  

The key of each document is (date:time:room number) 03_31_2012_12_00_room_2

Where each document houses 30 minutes worth of data.  So a room's key set will possibly look like this:

03_31_2012_12_00_room_2
03_31_2012_12_30_room_2
03_31_2012_13_00_room_2

The document is in JSON format.  It will have the following format:

{
	:overall => {
					:enter => 10, 
					:leave => 20, 
					:comment => 10, 
					:high_five => {'3' => [2], '2' => [4,1,5]}
				}
	:chat_log => [
					['2012-06-25 20:04:53 -0000', 'enter', 1]
					['2012-06-25 20:05:00 -0000', 'leave', 1]
					['2012-06-25 20:05:20 -0000', 'high_five', 1, 2]
					['2012-06-25 20:07:20 -0000', 'comment', 1 "Hello Jack"]
				]
}

Pros:
 - Scalable in the sense that as long as the database scales and the index on the document is linear, all pulls from the datbase should be near constant time.
 
Cons:
 - It will be hard to aggregate all chats by user.


-- API documentation
	Right now this is only a read-only API

	Required Parameters:
	- rid (ID of the room)
	
	Optional Parameters:
 	- g (Granularity: ['hour', 'minute']) (Default is 'minute')
	- format (['json', 'custom'])
	
	/logs.:format
	
	Response:
	
	
	
Something went wrong with that request. Please try again.