Check out example codes for "record count by month in rails". It will help you in understanding the concepts better.
Code Example 1
NewsFeed.count(:group=>"date_trunc('month', created_at)",:conditions=>"user_id NOT IN (?)",[exluded_ids])
Learn ReactJs, React Native from akashmittal.com