reverse query ams_index to produce list of augmented music_sessions
This commit is contained in:
parent
beca3b5608
commit
b918d24d32
|
|
@ -314,7 +314,7 @@ module JamRuby
|
|||
return query
|
||||
end
|
||||
|
||||
# Generate a list of active music sessions filtered by genre, language, keyword, and sorted
|
||||
# Generate a list of music sessions (that are active) 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 = {})
|
||||
|
|
@ -329,18 +329,23 @@ module JamRuby
|
|||
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(
|
||||
query = MusicSession
|
||||
.select('music_sessions.*')
|
||||
|
||||
# TODO this is not really needed when ams_music_session_tmp is joined
|
||||
# unless there is something specific we need out of active_music_sessions
|
||||
query = query.joins(
|
||||
%Q{
|
||||
INNER JOIN
|
||||
music_sessions
|
||||
active_music_sessions
|
||||
ON
|
||||
music_sessions.id = active_music_sessions.id
|
||||
active_music_sessions.id = music_sessions.id
|
||||
}
|
||||
)
|
||||
.select('1::integer as tag, 15::integer as latency')
|
||||
|
||||
# TODO integrate ams_music_session_tmp into the processing
|
||||
# then we can join ams_music_session_tmp and not join active_music_sessions
|
||||
# query = query.joins(
|
||||
# %Q{
|
||||
# INNER JOIN
|
||||
|
|
@ -349,6 +354,7 @@ module JamRuby
|
|||
# ams_music_session_tmp.music_session_id = active_music_sessions.id
|
||||
# }
|
||||
# )
|
||||
# .select('ams_music_session_tmp.tag, ams_music_session_tmp.latency')
|
||||
|
||||
query = query.order(
|
||||
%Q{
|
||||
|
|
@ -364,8 +370,9 @@ module JamRuby
|
|||
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...
|
||||
# cleanse keyword so it is only word characters. ignore if less than 3 characters long or greater than 100
|
||||
# TODO do we want to force match of whole words only? this matches any substring...
|
||||
# TODO do we want to match more than one word in the phrase? this matches only the first word...
|
||||
|
||||
unless keyword.nil? or keyword.length < 3 or keyword.length > 100
|
||||
w = keyword.split(/\W+/)
|
||||
|
|
@ -374,7 +381,7 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
query = query.where("music_sessions.genre_id in (?)", genres) unless genres.nil?
|
||||
query = query.where("music_sessions.genre_id = ?", genre) unless genre.nil?
|
||||
|
||||
# TODO filter by lang
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue