Fast Ruby algorithm to process query results
I'm running Rails. I have two models like this: class Movie < ActiveRecord::Base has_many :datapoints attr_accessible :date_time_published end class Datapoint < ActiveRecord::Base belongs_to :movie attr_accessible :cumulative_views, :timestamp end When I query the database for all the datapoints for a given set of movies in a given time period I get an array like this: # < Datapoint cumulative_views: 58, movie_id: "1", timestamp: "2012-06-16 18:21:12" > , # < Datapoint cumulative_views: 58, movie_id: "2", timestamp: "2012-06-19 14:14:36" > , # < Datapoint cumulative_views: 99, movie_id: "1", timestamp: "2012-06-18 12:13:08" > , ... I would like you to create a fast Ruby algorithm that converts it to an output format: "movies": [{ "movie_id": 1, "inc_views_per_day": [{ "jd": 2454115, "inc_views": 3 }, { "jd": 2454116, "inc_views": 4 }] }] Please see the detailed requirements for a full description, Regards, Derek.
| Expired |
Markéta Lacroix
Illustrator
View profile
Barbara Miles
Data Entry Specialist
View profile
Melissa Mostyn
Sales & Marketing Consultant
View profile
Kimberlee Ingram
Sales & Marketing Consultant
View profile
Related projects
Search for freelance jobscan’t wait for more clients
and advertising. Thank you."