stub out active_music_sessions#ams_index

This commit is contained in:
Scott Comer 2014-06-13 12:38:36 -05:00
parent ae6f82659a
commit beca3b5608
1 changed files with 67 additions and 0 deletions

View File

@ -314,6 +314,73 @@ module JamRuby
return query
end
# Generate a list of active music sessions filtered by genre, language, keyword, and sorted
# (and tagged) by rsvp'd (1st), invited (2nd), and musician can join (3rd). within a group
# tagged the same, sorted by score. date seems irrelevant as these are active sessions.
def self.ams_index(current_user, options = {})
client_id = options[:client_id]
genre = options[:genre]
lang = options[:lang]
keyword = options[:keyword]
offset = options[:offset]
limit = options[:limit]
connection = Connection.where(user_id: current_user.id, client_id: client_id).first!
my_locidispid = connection.locidispid
my_audio_latency = connection.last_jam_audio_latency
query = ActiveMusicSession
.select('active_music_sessions.*, 1 as tag, 15 as latency')
.joins(
%Q{
INNER JOIN
music_sessions
ON
music_sessions.id = active_music_sessions.id
}
)
# TODO integrate ams_music_session_tmp into the processing
# query = query.joins(
# %Q{
# INNER JOIN
# ams_music_session_tmp
# ON
# ams_music_session_tmp.music_session_id = active_music_sessions.id
# }
# )
query = query.order(
%Q{
tag, latency
}
)
if (offset)
query = query.offset(offset)
end
if (limit)
query = query.limit(limit)
end
# cleanse keyword so it is only word characters. ignore if less than 3 characters long or too long
# TODO do we want to force match of whole words only? this just picks the first word out...
unless keyword.nil? or keyword.length < 3 or keyword.length > 100
w = keyword.split(/\W+/)
if w.length > 0 and w.length >= 3
query = query.where("music_sessions.description like '%#{w[0]}%'")
end
end
query = query.where("music_sessions.genre_id in (?)", genres) unless genres.nil?
# TODO filter by lang
return query
end
def self.participant_create user, music_session_id, client_id, as_musician, tracks
music_session = MusicSession.find(music_session_id)