ActiveAdmin.register_page "Top Selling JamTracks" do
  menu :parent => 'Reports'

  top_selling_jamtracks = JamTrack.select([:id, :original_artist, :name, :has_tap_in]).find_by_sql("select count(jam_tracks.id) as count , jam_tracks.id, original_artist, name, (jmep_text is not null)  has_tap_in from jam_tracks inner join jam_track_rights on (jam_track_rights.jam_track_id = jam_tracks.id AND jam_track_rights.is_test_purchase = false) group by jam_tracks.id order by count(jam_tracks.id) desc ")

  content :title => "Top Selling JamTracks" do
    table_for top_selling_jamtracks do
      column "Count", :count
      column "Original Artist", :original_artist
      column "Name", :name
      column "Has Count-in", :has_tap_in

      column "ID", :id

    end

  end


end