vrfs-774: integrating results with UI
This commit is contained in:
parent
462e4034ec
commit
76c1b4ce0a
|
|
@ -13,7 +13,7 @@ module JamRuby
|
|||
|
||||
def self.order_param(params)
|
||||
ordering = params[:orderby]
|
||||
ordering.blank? ? ORDERING_KEYS[0] : ordering
|
||||
ordering.blank? ? ORDERING_KEYS[0] : ORDERING_KEYS.detect { |oo| oo.to_s == ordering }
|
||||
end
|
||||
|
||||
# performs a site-white search
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ module JamRuby
|
|||
|
||||
after_save :check_lat_lng
|
||||
|
||||
PARAM_SEARCH_MUSICIAN = :search_m
|
||||
|
||||
attr_accessible :first_name, :last_name, :email, :city, :password, :password_confirmation, :state, :country, :birth_date, :subscribe_email, :terms_of_service, :original_fpfile, :cropped_fpfile, :cropped_s3_path, :photo_url, :crop_selection, :lat, :lng
|
||||
|
||||
# updating_password corresponds to a lost_password
|
||||
|
|
@ -935,7 +937,7 @@ module JamRuby
|
|||
case ordering = Search.order_param(params)
|
||||
when :plays
|
||||
when :followed
|
||||
rel = rel.select("COUNT(follows) AS fcount, users.id")
|
||||
rel = rel.select("COUNT(follows) AS fcount, users.*")
|
||||
rel = rel.joins("LEFT JOIN users_followers AS follows ON follows.user_id = users.id")
|
||||
rel = rel.group("users.id")
|
||||
rel = rel.order("COUNT(follows) DESC")
|
||||
|
|
@ -944,7 +946,7 @@ module JamRuby
|
|||
perpage = params[:per_page] || 20
|
||||
page = [params[:page].to_i, 1].max
|
||||
rel = rel.paginate(:page => page, :per_page => perpage)
|
||||
# puts rel.to_sql
|
||||
rel.includes([:instruments])
|
||||
rel
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
var logger = context.JK.logger;
|
||||
var musicians = {};
|
||||
var musicianList;
|
||||
var instrument_logo_map = context.JK.getInstrumentIconMap24();
|
||||
|
||||
function removeSpinner() {
|
||||
$('<div[layout-id=findMusician] .content .spinner').remove();
|
||||
|
|
@ -36,33 +37,25 @@
|
|||
function search() {
|
||||
logger.debug("Searching for musicians...");
|
||||
clearResults();
|
||||
var queryString = 'musicians=1&';
|
||||
var queryString = 'search_m=1&';
|
||||
|
||||
// order by
|
||||
var orderby = $('.musician-order-by').val();
|
||||
if (orderby !== null && orderby.length() > 0) {
|
||||
if (typeof orderby != 'undefined' && orderby.length > 0) {
|
||||
queryString += "orderby=" + orderby + '&';
|
||||
}
|
||||
// instrument filter
|
||||
var instrument = $('.instrument-list').val();
|
||||
if (instruments !== null && instruments.length() > 0) {
|
||||
queryString += "instrument=" + instrument;
|
||||
if (typeof instrument != 'undefined' && !(instrument === '')) {
|
||||
queryString += "instrument=" + instrument + '&';
|
||||
}
|
||||
// distance filter
|
||||
var query_param = $('#musician-query-distance').val();
|
||||
var query_param = $('#musician_query_distance').val();
|
||||
if (query_param !== null && query_param.length > 0) {
|
||||
var matches = query_param.match(/(\d)/);
|
||||
if (0 < matches.length()) {
|
||||
var matches = query_param.match(/(\d+)/);
|
||||
if (0 < matches.length) {
|
||||
var distance = matches[0];
|
||||
query_param = $('#musician-query-center').val();
|
||||
if (query_param !== null && query_param.length > 0) {
|
||||
matches = query_param.match(/\\d{5}(-\\d{4})?/);
|
||||
if (0 < matches.length()) {
|
||||
var zip = matches[0];
|
||||
queryString += "zip=" + query_param + '&';
|
||||
queryString += "distance=" + query_param + '&';
|
||||
}
|
||||
}
|
||||
queryString += "distance=" + distance + '&';
|
||||
}
|
||||
}
|
||||
loadMusicians(queryString);
|
||||
|
|
@ -77,29 +70,38 @@
|
|||
var $noMusiciansFound = $('#musicians-none-found');
|
||||
if(musicianList.length == 0) {
|
||||
$noMusiciansFound.show();
|
||||
musicians = [];
|
||||
}
|
||||
else {
|
||||
$noMusiciansFound.hide();
|
||||
musicians = musicianList;
|
||||
renderMusicians();
|
||||
}
|
||||
|
||||
startMusicianLatencyChecks(musicianList);
|
||||
context.JK.GA.trackFindMusicians(musicianList.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a single musician line into the table.
|
||||
* It will be inserted at the appropriate place according to the
|
||||
* sortScore in musicianLatency.
|
||||
* Render a list of musicians
|
||||
*/
|
||||
function renderMusician(musicianId) {
|
||||
// store musician in the appropriate bucket and increment category counts
|
||||
var musician = musicians[musicianId];
|
||||
|
||||
refreshDisplay();
|
||||
function renderMusicians() {
|
||||
var ii, len;
|
||||
var mTemplate = $('#template-find-musician-row').html();
|
||||
var mVals, mm, renderings='';
|
||||
var instrument_html;
|
||||
for (ii=0, len=musicians.length; ii < len; ii++) {
|
||||
mm = musicians[ii];
|
||||
mVals = {
|
||||
avatar_url: context.JK.resolveAvatarUrl(mm.photo_url),
|
||||
profile_url: "/#/profile/" + mm.id,
|
||||
musician_name: mm.name,
|
||||
musician_location: mm.city + ', ' + mm.state,
|
||||
instruments: instrument_html
|
||||
};
|
||||
renderings += context.JK.fillTemplate(mTemplate, mVals);
|
||||
}
|
||||
$('#musician-filter-results').append(renderings);
|
||||
}
|
||||
|
||||
function beforeShow(data) {
|
||||
context.JK.InstrumentSelectorHelper.render('#find-musician-instrument');
|
||||
}
|
||||
|
||||
function afterShow(data) {
|
||||
|
|
@ -123,33 +125,28 @@
|
|||
search();
|
||||
}
|
||||
});
|
||||
$('#btn-refresh').on("click", search);
|
||||
$('#btn-refresh-musicians').on("click", search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize, providing an instance of the MusicianLatency class.
|
||||
* Initialize,
|
||||
*/
|
||||
function initialize(latency) {
|
||||
function initialize() {
|
||||
|
||||
var screenBindings = {
|
||||
'beforeShow': beforeShow,
|
||||
'afterShow': afterShow
|
||||
};
|
||||
app.bindScreen('findMusician', screenBindings);
|
||||
|
||||
musicianList = new context.JK.MusicianList(app);
|
||||
app.bindScreen('musicians', screenBindings);
|
||||
|
||||
events();
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
this.renderMusician = renderMusician;
|
||||
this.renderMusicians = renderMusicians;
|
||||
this.afterShow = afterShow;
|
||||
|
||||
// Following exposed for easier testing.
|
||||
this.setMusician = setMusician;
|
||||
this.clearResults = clearResults;
|
||||
this.getCategoryEnum = getCategoryEnum;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,14 @@ class ApiSearchController < ApiController
|
|||
respond_to :json
|
||||
|
||||
def index
|
||||
@search = Search.search(params[:query], current_user.id)
|
||||
if 1 == params[User::PARAM_SEARCH_MUSICIAN].to_i
|
||||
logger.debug("*** params = #{params.inspect}")
|
||||
query = params.clone
|
||||
query[:remote_ip] = request.remote_ip
|
||||
@search = User.musician_search(query, current_user)
|
||||
respond_with @users, responder: ApiResponder, :status => 200
|
||||
else
|
||||
@search = Search.search(params[:query], current_user.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ class ApiUsersController < ApiController
|
|||
respond_to :json
|
||||
|
||||
def index
|
||||
if 1 == params[:musicians].to_i
|
||||
if 1 == params[User::PARAM_SEARCH_MUSICIAN].to_i
|
||||
logger.debug("*** params = #{params.inspect}")
|
||||
query = params.clone
|
||||
query[:remote_ip] = request.remote_ip
|
||||
@users = User.musician_search(query, current_user)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
collection @users
|
||||
|
||||
# do not retrieve all child collections when showing a list of users
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :email, :online, :musician, :photo_url, :biography
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :email, :online, :musician, :photo_url, :biography
|
||||
|
||||
if 1 == params[User::PARAM_SEARCH_MUSICIAN].to_i
|
||||
child :instruments do
|
||||
attributes :id
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@
|
|||
<!-- instrument filter -->
|
||||
<div id="find-musician-instrument" class="right ml10">
|
||||
<%= select_tag(:instrument,
|
||||
options_for_select(['Select Instrument', ''].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] })),
|
||||
options_for_select([['Select Instrument', '']].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] })),
|
||||
{:class => 'instrument-list'} ) %>
|
||||
</div>
|
||||
|
||||
<!-- distance filter -->
|
||||
Within
|
||||
<div class="query-distance-params" style="height:25px;">
|
||||
<input id="musician-query-distance" type="text" name="query-distance" placeholder="100" />
|
||||
miles of
|
||||
<input id="musician_query_distance" type="text" name="query_distance" value="100" placeholder="100" />
|
||||
miles from
|
||||
<%= current_user.current_city(request.remote_ip) %>
|
||||
</div>
|
||||
<div class="right mr10">
|
||||
<a id="btn-refresh" href="#/findMusician" style="text-decoration:none;" class="button-grey">REFRESH</a>
|
||||
<a id="btn-refresh-musicians" style="text-decoration:none;" class="button-grey">REFRESH</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</div>
|
||||
<div class="content-scroller">
|
||||
<div class="content-wrapper" style="padding-left:35px;padding-top:10px;">
|
||||
<div id="filter-results">
|
||||
<div id="musician-filter-results">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -26,3 +26,50 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Session Row Template -->
|
||||
<script type="text/template" id="template-find-musician-row">
|
||||
<div class="list-result">
|
||||
|
||||
<!-- avatar -->
|
||||
<div class="avatar-small"><img src="{avatar_url}" /></div>
|
||||
|
||||
<!-- name & location -->
|
||||
<div class="result-name">{musician_name}<br />
|
||||
<span class="result-location">{musician_location}
|
||||
<br /><br />
|
||||
<div id="result_instruments" class="nowrap">
|
||||
{instruments}
|
||||
</div>
|
||||
<br clear="all" /><br />
|
||||
122 <img src="images/content/icon_friend.png" width="14" height="12" align="absmiddle" /> 4 <img src="images/content/icon_followers.png" width="22" height="12" align="absmiddle" /> 17 <img src="images/content/icon_recordings.png" width="12" height="13" align="absmiddle" /> 64 <img src="images/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" /></span><br /><br />
|
||||
|
||||
</div>
|
||||
<div class="left ml35 f11 whitespace w40"><br />
|
||||
Nulla facilisi. In vel sem. Morbi id urna in diam dignissim feugiat. Proin molestie tortor eu velit. Aliquam erat volutpat. Nullam ultrices, diam tempus vulputate egestas, eros pede varius leo, sed imperdiet lectus est ornare odio.<br />
|
||||
<br />
|
||||
<a href="#" class="button-orange smallbutton m0">PROFILE</a><a href="#" class="button-orange smallbutton">LIKE</a><a href="#" class="button-orange smallbutton m0">FRIEND</a><a href="#" class="button-orange smallbutton">FOLLOW</a></div>
|
||||
<div class="left ml10 w20">
|
||||
<br />
|
||||
<small><strong>FOLLOWING:</strong></small>
|
||||
<table class="musicians" cellpadding="0" cellspacing="5">
|
||||
<tr>
|
||||
<td width="24"><a href="#" class="avatar-tiny"><img src="images/content/avatar_band3.jpg" /></a></td>
|
||||
<td><a href="#"><strong>Fox Force Five</strong></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="24"><a href="#" class="avatar-tiny"><img src="images/content/avatar_band1.jpg" /></a></td>
|
||||
<td><a href="#"><strong>Tammany Hall</strong></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="24"><a href="#" class="avatar-tiny"><img src="images/content/avatar_band2.jpg" /></a></td>
|
||||
<td><a href="#"><strong>Bethany Grey</strong></a></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
</div>
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -143,6 +143,13 @@
|
|||
}
|
||||
findSessionScreen.initialize(sessionLatency);
|
||||
|
||||
var findMusicianScreen = new JK.FindMusicianScreen(JK.app);
|
||||
findMusicianScreen.initialize();
|
||||
/*if (!("jamClient" in window)) {
|
||||
var findMusicianScreen = new JK.FindMusicianScreen(JK.app);
|
||||
findMusicianScreen.initialize();
|
||||
}*/
|
||||
|
||||
var sessionScreen = new JK.SessionScreen(JK.app);
|
||||
sessionScreen.initialize();
|
||||
var sessionSettingsDialog = new JK.SessionSettingsDialog(JK.app, sessionScreen);
|
||||
|
|
|
|||
Loading…
Reference in New Issue