Merge branch 'develop' into vrfs1110
This commit is contained in:
commit
4dd15d1146
|
|
@ -1,7 +1,8 @@
|
|||
.idea
|
||||
*~
|
||||
*.swp
|
||||
*/vendor/*
|
||||
*/vendor/bundle
|
||||
*/vendor/cache
|
||||
HTML
|
||||
.DS_Store
|
||||
coverage/
|
||||
|
|
|
|||
|
|
@ -107,4 +107,7 @@ recordings_all_discarded.sql
|
|||
recordings_via_admin_web.sql
|
||||
relax_band_model_varchar.sql
|
||||
add_piano.sql
|
||||
feed.sql
|
||||
feed.sql
|
||||
like_follower_poly_assoc.sql
|
||||
feed_use_recording.sql
|
||||
feed_autoincrement_primary_key.sql
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
DROP TABLE feeds;
|
||||
|
||||
CREATE TABLE feeds (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
recording_id VARCHAR(64) UNIQUE REFERENCES recordings(id) ON DELETE CASCADE,
|
||||
music_session_id VARCHAR(64) UNIQUE REFERENCES music_sessions_history(id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
DELETE from feeds;
|
||||
|
||||
ALTER TABLE feeds DROP COLUMN claimed_recording_id;
|
||||
ALTER TABLE feeds ADD COLUMN recording_id VARCHAR(64) UNIQUE REFERENCES recordings(id) ON DELETE CASCADE;
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
drop table if exists users_followers;
|
||||
drop table if exists users_likers;
|
||||
drop table if exists bands_followers;
|
||||
drop table if exists bands_likers;
|
||||
|
||||
CREATE TABLE likes
|
||||
(
|
||||
id character varying(64) NOT NULL DEFAULT uuid_generate_v4(),
|
||||
user_id character varying(64) NOT NULL,
|
||||
likable_id character varying(64) NOT NULL,
|
||||
likable_type character varying(25) NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT now(),
|
||||
updated_at timestamp without time zone NOT NULL DEFAULT now(),
|
||||
CONSTRAINT likes_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT likes_user_fkey FOREIGN KEY (user_id) REFERENCES users (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT likes_user_uniqkey UNIQUE (user_id, likable_id)
|
||||
);
|
||||
|
||||
CREATE TABLE follows
|
||||
(
|
||||
id character varying(64) NOT NULL DEFAULT uuid_generate_v4(),
|
||||
user_id character varying(64) NOT NULL,
|
||||
followable_id character varying(64) NOT NULL,
|
||||
followable_type character varying(25) NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT now(),
|
||||
updated_at timestamp without time zone NOT NULL DEFAULT now(),
|
||||
CONSTRAINT follows_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT follows_user_fkey FOREIGN KEY (user_id) REFERENCES users (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT follows_user_uniqkey UNIQUE (user_id, followable_id)
|
||||
);
|
||||
|
|
@ -67,29 +67,24 @@ require "jam_ruby/models/invited_user"
|
|||
require "jam_ruby/models/invited_user_observer"
|
||||
require "jam_ruby/models/artifact_update"
|
||||
require "jam_ruby/models/band_invitation"
|
||||
require "jam_ruby/models/band_liker"
|
||||
require "jam_ruby/models/band_follower"
|
||||
require "jam_ruby/models/band_following"
|
||||
require "jam_ruby/models/band_musician"
|
||||
require "jam_ruby/models/connection"
|
||||
require "jam_ruby/models/friendship"
|
||||
require "jam_ruby/models/music_session"
|
||||
require "jam_ruby/models/music_session_comment"
|
||||
require "jam_ruby/models/music_session_liker"
|
||||
require "jam_ruby/models/music_session_history"
|
||||
require "jam_ruby/models/music_session_liker"
|
||||
require "jam_ruby/models/music_session_user_history"
|
||||
require "jam_ruby/models/music_session_perf_data"
|
||||
require "jam_ruby/models/invitation"
|
||||
require "jam_ruby/models/fan_invitation"
|
||||
require "jam_ruby/models/friend_request"
|
||||
require "jam_ruby/models/instrument"
|
||||
require "jam_ruby/models/like"
|
||||
require "jam_ruby/models/follow"
|
||||
require "jam_ruby/models/musician_instrument"
|
||||
require "jam_ruby/models/notification"
|
||||
require "jam_ruby/models/track"
|
||||
require "jam_ruby/models/user_liker"
|
||||
require "jam_ruby/models/user_like"
|
||||
require "jam_ruby/models/user_follower"
|
||||
require "jam_ruby/models/user_following"
|
||||
require "jam_ruby/models/search"
|
||||
require "jam_ruby/models/recording"
|
||||
require "jam_ruby/models/recording_comment"
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class MixUploader < CarrierWave::Uploader::Base
|
|||
system(ffmpeg_cmd)
|
||||
|
||||
unless $? == 0
|
||||
raise "ffmpeg metadata copy failed"
|
||||
raise "ffmpeg metadata copy failed. cmd=#{ffmpeg_cmd}"
|
||||
end
|
||||
|
||||
FileUtils.mv output_file, input_file
|
||||
|
|
@ -67,7 +67,7 @@ class MixUploader < CarrierWave::Uploader::Base
|
|||
system(ffmpeg_cmd)
|
||||
|
||||
unless $? == 0
|
||||
raise "ffmpeg mp3 convert failed"
|
||||
raise "ffmpeg mp3 convert failed. cmd=#{ffmpeg_cmd}"
|
||||
end
|
||||
|
||||
model.mp3_md5 = Digest::MD5.file(output_file).hexdigest
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class RecordedTrackUploader < CarrierWave::Uploader::Base
|
|||
system(ffmpeg_cmd)
|
||||
|
||||
unless $? == 0
|
||||
raise "ffmpeg failed"
|
||||
raise "ffmpeg failed. cmd: #{ffmpeg_cmd}"
|
||||
end
|
||||
|
||||
FileUtils.mv output_file, input_file
|
||||
|
|
|
|||
|
|
@ -26,15 +26,11 @@ module JamRuby
|
|||
# recordings
|
||||
has_many :recordings, :class_name => "JamRuby::Recording", :foreign_key => "band_id"
|
||||
|
||||
# likers
|
||||
has_many :likers, :class_name => "JamRuby::BandLiker", :foreign_key => "band_id", :inverse_of => :band
|
||||
has_many :inverse_likers, :through => :likers, :class_name => "JamRuby::User", :foreign_key => "liker_id"
|
||||
# self.id = likable_id in likes table
|
||||
has_many :likers, :as => :likable, :class_name => "JamRuby::Like", :dependent => :destroy
|
||||
|
||||
# followers
|
||||
has_many :band_followers, :class_name => "JamRuby::BandFollower", :foreign_key => "band_id"
|
||||
has_many :followers, :through => :band_followers, :class_name => "JamRuby::User"
|
||||
has_many :inverse_band_followers, :through => :followers, :class_name => "JamRuby::BandFollower", :foreign_key => "follower_id"
|
||||
has_many :inverse_followers, :through => :inverse_band_followers, :source => :band, :class_name => "JamRuby::Band"
|
||||
# self.id = followable_id in follows table
|
||||
has_many :followers, :as => :followable, :class_name => "JamRuby::Follow", :dependent => :destroy
|
||||
|
||||
# invitations
|
||||
has_many :invitations, :inverse_of => :band, :class_name => "JamRuby::BandInvitation", :foreign_key => "band_id"
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
module JamRuby
|
||||
class BandFollower < ActiveRecord::Base
|
||||
|
||||
self.table_name = "bands_followers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :band, :class_name => "JamRuby::Band", :foreign_key => "band_id"
|
||||
belongs_to :follower, :class_name => "JamRuby::User", :foreign_key => "follower_id"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
module JamRuby
|
||||
class BandFollowing < ActiveRecord::Base
|
||||
|
||||
self.table_name = "bands_followers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "follower_id", :inverse_of => :inverse_band_followings
|
||||
belongs_to :band_following, :class_name => "JamRuby::Band", :foreign_key => "band_id", :inverse_of => :band_followings
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
module JamRuby
|
||||
class BandLiker < ActiveRecord::Base
|
||||
|
||||
self.table_name = "bands_likers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :band, :class_name => "JamRuby::Band", :foreign_key => "band_id", :inverse_of => :likers
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id", :inverse_of => :band_likes
|
||||
end
|
||||
end
|
||||
|
|
@ -3,13 +3,12 @@ module JamRuby
|
|||
|
||||
attr_accessible :name, :description, :is_public, :is_downloadable, :genre_id, :recording_id, :user_id, as: :admin
|
||||
|
||||
belongs_to :recording, :class_name => "JamRuby::Recording", :inverse_of => :claimed_recordings
|
||||
belongs_to :recording, :class_name => "JamRuby::Recording", :inverse_of => :claimed_recordings, :foreign_key => 'recording_id'
|
||||
belongs_to :user, :class_name => "JamRuby::User", :inverse_of => :claimed_recordings
|
||||
belongs_to :genre, :class_name => "JamRuby::Genre"
|
||||
has_many :recorded_tracks, :through => :recording, :class_name => "JamRuby::RecordedTrack"
|
||||
has_many :playing_sessions, :class_name => "JamRuby::MusicSession"
|
||||
has_one :share_token, :class_name => "JamRuby::ShareToken", :inverse_of => :shareable, :foreign_key => 'shareable_id'
|
||||
has_one :feed, :class_name => "JamRuby::Feed", :inverse_of => :claimed_recording, :foreign_key => 'claimed_recording_id', :dependent => :destroy
|
||||
|
||||
|
||||
validates :name, no_profanity: true, length: {minimum: 3, maximum: 64}, presence: true
|
||||
|
|
@ -21,17 +20,11 @@ module JamRuby
|
|||
validates_uniqueness_of :user_id, :scope => :recording_id
|
||||
validate :user_belongs_to_recording
|
||||
|
||||
before_create :add_to_feed
|
||||
before_create :generate_share_token
|
||||
|
||||
SHARE_TOKEN_LENGTH = 8
|
||||
|
||||
|
||||
def add_to_feed
|
||||
feed = Feed.new
|
||||
feed.claimed_recording = self
|
||||
end
|
||||
|
||||
def user_belongs_to_recording
|
||||
if user && recording && !recording.users.exists?(user)
|
||||
errors.add(:user, ValidationMessages::NOT_PART_OF_RECORDING)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
module JamRuby
|
||||
class Feed < ActiveRecord::Base
|
||||
|
||||
belongs_to :claimed_recording, class_name: "JamRuby::ClaimedRecording", inverse_of: :feed, foreign_key: 'claimed_recording_id'
|
||||
belongs_to :recording, class_name: "JamRuby::Recording", inverse_of: :feed, foreign_key: 'recording_id'
|
||||
belongs_to :music_session_history, class_name: "JamRuby::MusicSessionHistory", inverse_of: :feed, foreign_key: 'music_session_id'
|
||||
|
||||
def self.index(params = {})
|
||||
Feed.includes(:claimed_recording).includes(:music_session_history).order('created_at DESC').limit(20)
|
||||
def self.index(params = {start:0, limit:20})
|
||||
Feed.includes(:recording).includes(:music_session_history).order('created_at DESC').offset(params[:start]).limit(params[:limit])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
module JamRuby
|
||||
class Follow < ActiveRecord::Base
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id"
|
||||
belongs_to :followable, :polymorphic => true
|
||||
|
||||
def type
|
||||
type = self.followable_type.gsub("JamRuby::", "").downcase
|
||||
type
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module JamRuby
|
||||
class Like < ActiveRecord::Base
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id"
|
||||
belongs_to :likable, :polymorphic => true
|
||||
|
||||
def type
|
||||
type = self.likable_type.gsub("JamRuby::", "").downcase
|
||||
type
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -9,16 +9,18 @@ module JamRuby
|
|||
self.primary_key = 'id'
|
||||
|
||||
attr_accessible :ogg_url, :should_retry, as: :admin
|
||||
attr_writer :is_skip_mount_uploader
|
||||
attr_accessor :is_skip_mount_uploader
|
||||
|
||||
belongs_to :recording, :class_name => "JamRuby::Recording", :inverse_of => :mixes, :foreign_key => 'recording_id'
|
||||
|
||||
skip_callback :save, :before, :store_picture!, if: :is_skip_mount_uploader
|
||||
|
||||
mount_uploader :ogg_url, MixUploader
|
||||
|
||||
|
||||
before_validation do
|
||||
# this should be an activeadmin only path, because it's using the mount_uploader (whereas the client does something completely different)
|
||||
if ogg_url.present? && ogg_url.respond_to?(:file) && ogg_url_changed?
|
||||
if !is_skip_mount_uploader && ogg_url.present? && ogg_url.respond_to?(:file) && ogg_url_changed?
|
||||
self.ogg_length = ogg_url.file.size
|
||||
self.ogg_md5 = ogg_url.md5
|
||||
self.completed = true
|
||||
|
|
@ -34,6 +36,7 @@ module JamRuby
|
|||
raise if recording.nil?
|
||||
|
||||
mix = Mix.new
|
||||
mix.is_skip_mount_uploader = true
|
||||
mix.recording = recording
|
||||
mix.save
|
||||
mix[:ogg_url] = construct_filename(mix.created_at, recording.id, mix.id, type='ogg')
|
||||
|
|
@ -41,6 +44,7 @@ module JamRuby
|
|||
if mix.save
|
||||
mix.enqueue
|
||||
end
|
||||
mix.is_skip_mount_uploader = false
|
||||
|
||||
mix
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ module JamRuby
|
|||
|
||||
has_many :music_session_user_histories, :class_name => "JamRuby::MusicSessionUserHistory", :foreign_key => "music_session_id"
|
||||
has_many :comments, :class_name => "JamRuby::MusicSessionComment", :foreign_key => "music_session_id"
|
||||
has_many :likes, :class_name => "JamRuby::MusicSessionLiker", :foreign_key => "music_session_id"
|
||||
has_many :likes, :class_name => "JamRuby::MusicSessionLiker", :foreign_key => "session_id"
|
||||
has_one :share_token, :class_name => "JamRuby::ShareToken", :inverse_of => :shareable, :foreign_key => 'shareable_id'
|
||||
has_one :feed, :class_name => "JamRuby::Feed", :inverse_of => :music_session_history, :foreign_key => 'music_session_id', :dependent => :destroy
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ module JamRuby
|
|||
|
||||
def retrieve_user_followers(connection, user_id)
|
||||
follower_ids = []
|
||||
connection.exec("SELECT uf.follower_id as friend_id FROM users_followers uf WHERE uf.user_id = $1", [user_id]) do |follower_results|
|
||||
connection.exec("SELECT u.user_id as follower_id FROM follows f WHERE f.followable_id = $1", [user_id]) do |follower_results|
|
||||
follower_results.each do |follower_result|
|
||||
follower_ids.push(follower_result['follower_id'])
|
||||
end
|
||||
|
|
@ -460,11 +460,11 @@ module JamRuby
|
|||
if music_session.musician_access || music_session.fan_access
|
||||
|
||||
friends = Friendship.where(:friend_id => user.id)
|
||||
user_followers = UserFollower.where(:user_id => user.id)
|
||||
user_followers = user.followers
|
||||
|
||||
# construct an array of User objects representing friends and followers
|
||||
friend_users = friends.map { |fu| fu.user }
|
||||
follower_users = user_followers.map { |uf| uf.follower }
|
||||
follower_users = user_followers.map { |uf| uf.user }
|
||||
friends_and_followers = friend_users.concat(follower_users).uniq
|
||||
|
||||
# remove anyone in the session
|
||||
|
|
@ -509,22 +509,21 @@ module JamRuby
|
|||
# if the session is private, don't send any notifications
|
||||
if music_session.musician_access || music_session.fan_access
|
||||
|
||||
band_followers = BandFollower.where(:band_id => band.id)
|
||||
|
||||
notifications, online_followers, offline_followers = [], [], []
|
||||
notification_msg = format_msg(NotificationTypes::BAND_SESSION_JOIN, nil, band)
|
||||
|
||||
band_followers.each do |bf|
|
||||
if (bf.follower.musician && music_session.musician_access) || (!bf.follower.musician && music_session.fan_access)
|
||||
band.followers.each do |bf|
|
||||
follower = bf.user
|
||||
if (follower.musician && music_session.musician_access) || (!follower.musician && music_session.fan_access)
|
||||
notification = Notification.new
|
||||
notification.band_id = band.id
|
||||
notification.description = NotificationTypes::BAND_SESSION_JOIN
|
||||
notification.target_user_id = bf.follower.id
|
||||
notification.target_user_id = follower.id
|
||||
notification.save
|
||||
|
||||
if bf.follower.online
|
||||
if follower.online
|
||||
msg = @@message_factory.band_session_join(
|
||||
bf.follower.id,
|
||||
follower.id,
|
||||
music_session.id,
|
||||
band.photo_url,
|
||||
notification_msg,
|
||||
|
|
@ -532,9 +531,9 @@ module JamRuby
|
|||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(bf.follower.id, msg)
|
||||
@@mq_router.publish_to_user(follower.id, msg)
|
||||
else
|
||||
offline_followers << bf.follower
|
||||
offline_followers << follower
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -551,11 +550,11 @@ module JamRuby
|
|||
user = recording.owner
|
||||
|
||||
friends = Friendship.where(:friend_id => user.id)
|
||||
user_followers = UserFollower.where(:user_id => user.id)
|
||||
user_followers = user.followers
|
||||
|
||||
# construct an array of User objects representing friends and followers
|
||||
friend_users = friends.map { |fu| fu.friend }
|
||||
follower_users = user_followers.map { |uf| uf.follower }
|
||||
follower_users = user_followers.map { |uf| uf.user }
|
||||
friends_and_followers = friend_users.concat(follower_users).uniq
|
||||
|
||||
notifications, online_ff, offline_ff = [], [], []
|
||||
|
|
@ -592,20 +591,20 @@ module JamRuby
|
|||
|
||||
def send_band_recording_saved(recording)
|
||||
|
||||
band_followers = BandFollower.where(:band_id => band.id)
|
||||
notification_msg = format_msg(NotificationTypes::BAND_RECORDING_SAVED, nil, recording.band)
|
||||
|
||||
band_followers.each do |bf|
|
||||
band.followers.each do |bf|
|
||||
follower = bf.user
|
||||
notification = Notification.new
|
||||
notification.description = NotificationTypes::BAND_RECORDING_SAVED
|
||||
notification.band_id = band.id
|
||||
notification.target_user_id = bf.follower.id
|
||||
notification.target_user_id = follower.id
|
||||
notification.recording_id = recording.id
|
||||
notification.save
|
||||
|
||||
if bf.follower.online
|
||||
if follower.online
|
||||
msg = @@message_factory.band_recording_saved(
|
||||
bf.follower.id,
|
||||
follower.id,
|
||||
recording.id,
|
||||
band.photo_url,
|
||||
notification_msg,
|
||||
|
|
@ -615,7 +614,7 @@ module JamRuby
|
|||
|
||||
@@mq_router.publish_to_user(of.id, notification_msg)
|
||||
else
|
||||
offline_followers << bf.follower
|
||||
offline_followers << follower
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -130,4 +130,10 @@ class JamRuby::PromoLatest < JamRuby::Promotional
|
|||
self.class.latest_display_name(self.latest)
|
||||
end
|
||||
|
||||
def self.active_latests
|
||||
self.where(:aasm_state => 'active')
|
||||
.all
|
||||
.map(&:latest)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
def upload_sign(content_md5)
|
||||
s3_manager.upload_sign(url, content_md5, next_part_to_upload, upload_id)
|
||||
s3_manager.upload_sign(self[:url], content_md5, next_part_to_upload, upload_id)
|
||||
end
|
||||
|
||||
def upload_part_complete(part, offset)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module JamRuby
|
|||
# if we see that a part was just uploaded entirely, validate that we can find the part that was just uploaded
|
||||
if recorded_track.is_part_uploading_was && !recorded_track.is_part_uploading
|
||||
begin
|
||||
aws_part = recorded_track.s3_manager.multiple_upload_find_part(recorded_track.url, recorded_track.upload_id, recorded_track.next_part_to_upload - 1)
|
||||
aws_part = recorded_track.s3_manager.multiple_upload_find_part(recorded_track[:url], recorded_track.upload_id, recorded_track.next_part_to_upload - 1)
|
||||
# calling size on a part that does not exist will throw an exception... that's what we want
|
||||
aws_part.size
|
||||
rescue SocketError => e
|
||||
|
|
@ -29,7 +29,7 @@ module JamRuby
|
|||
|
||||
multipart_success = false
|
||||
begin
|
||||
recorded_track.s3_manager.multipart_upload_complete(recorded_track.url, recorded_track.upload_id)
|
||||
recorded_track.s3_manager.multipart_upload_complete(recorded_track[:url], recorded_track.upload_id)
|
||||
multipart_success = true
|
||||
rescue SocketError => e
|
||||
raise # this should cause a 500 error, which is what we want. The client will retry later.
|
||||
|
|
@ -66,7 +66,7 @@ module JamRuby
|
|||
# save upload id before we abort this bad boy
|
||||
upload_id = recorded_track.upload_id
|
||||
begin
|
||||
recorded_track.s3_manager.multipart_upload_abort(recorded_track.url, upload_id)
|
||||
recorded_track.s3_manager.multipart_upload_abort(recorded_track[:url], upload_id)
|
||||
rescue => e
|
||||
puts e.inspect
|
||||
end
|
||||
|
|
@ -82,7 +82,7 @@ module JamRuby
|
|||
def before_save(recorded_track)
|
||||
# if we are on the 1st part, then we need to make sure we can save the upload_id
|
||||
if recorded_track.next_part_to_upload == 1
|
||||
recorded_track.upload_id = recorded_track.s3_manager.multipart_upload_start(recorded_track.url)
|
||||
recorded_track.upload_id = recorded_track.s3_manager.multipart_upload_start(recorded_track[:url])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ module JamRuby
|
|||
has_many :comments, :class_name => "JamRuby::RecordingComment", :foreign_key => "recording_id"
|
||||
has_many :likes, :class_name => "JamRuby::RecordingLiker", :foreign_key => "recording_id"
|
||||
has_many :plays, :class_name => "JamRuby::RecordingPlay", :foreign_key => "recording_id"
|
||||
has_one :feed, :class_name => "JamRuby::Feed", :inverse_of => :recording, :foreign_key => 'recording_id', :dependent => :destroy
|
||||
|
||||
belongs_to :owner, :class_name => "JamRuby::User", :inverse_of => :owned_recordings, :foreign_key => 'owner_id'
|
||||
belongs_to :band, :class_name => "JamRuby::Band", :inverse_of => :recordings
|
||||
|
|
@ -26,6 +27,13 @@ module JamRuby
|
|||
validate :only_one_mix
|
||||
|
||||
before_save :sanitize_active_admin
|
||||
before_create :add_to_feed
|
||||
|
||||
|
||||
def add_to_feed
|
||||
feed = Feed.new
|
||||
feed.recording = self
|
||||
end
|
||||
|
||||
def sanitize_active_admin
|
||||
self.owner_id = nil if self.owner_id == ''
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ module JamRuby
|
|||
.order("play_count DESC, users.created_at DESC")
|
||||
when :followed
|
||||
sel_str = "COUNT(follows) AS search_follow_count, #{sel_str}"
|
||||
rel = rel.joins("LEFT JOIN users_followers AS follows ON follows.user_id = users.id")
|
||||
rel = rel.joins("LEFT JOIN follows ON follows.followable_id = users.id")
|
||||
.group("users.id")
|
||||
.order("COUNT(follows) DESC, users.created_at DESC")
|
||||
when :playing
|
||||
|
|
@ -185,7 +185,7 @@ module JamRuby
|
|||
@results.each do |uu|
|
||||
counters = { }
|
||||
counters[COUNT_FRIEND] = Friendship.where(:user_id => uu.id).count
|
||||
counters[COUNT_FOLLOW] = UserFollowing.where(:user_id => uu.id).count
|
||||
counters[COUNT_FOLLOW] = Follow.where(:followable_id => uu.id).count
|
||||
counters[COUNT_RECORD] = ClaimedRecording.where(:user_id => uu.id).count
|
||||
counters[COUNT_SESSION] = MusicSession.where(:user_id => uu.id).count
|
||||
@user_counters[uu.id] << counters
|
||||
|
|
@ -194,8 +194,8 @@ module JamRuby
|
|||
# this section determines follow/like/friend status for each search result
|
||||
# so that action links can be activated or not
|
||||
rel = User.select("users.id AS uid")
|
||||
rel = rel.joins("LEFT JOIN users_followers AS follows ON follows.follower_id = '#{user.id}'")
|
||||
rel = rel.where(["users.id IN (#{mids}) AND follows.user_id = users.id"])
|
||||
rel = rel.joins("LEFT JOIN follows ON follows.user_id = '#{user.id}'")
|
||||
rel = rel.where(["users.id IN (#{mids}) AND follows.followable_id = users.id"])
|
||||
rel.all.each { |val| @user_counters[val.uid] << RESULT_FOLLOW }
|
||||
|
||||
rel = User.select("users.id AS uid")
|
||||
|
|
@ -307,7 +307,7 @@ module JamRuby
|
|||
.order("play_count DESC, bands.created_at DESC")
|
||||
when :followed
|
||||
sel_str = "COUNT(follows) AS search_follow_count, #{sel_str}"
|
||||
rel = rel.joins("LEFT JOIN bands_followers AS follows ON follows.band_id = bands.id")
|
||||
rel = rel.joins("LEFT JOIN follows ON follows.followable_id = bands.id")
|
||||
.group("bands.id")
|
||||
.order("COUNT(follows) DESC, bands.created_at DESC")
|
||||
when :playing
|
||||
|
|
@ -336,7 +336,7 @@ module JamRuby
|
|||
# this gets counts for each search result
|
||||
@results.each do |bb|
|
||||
counters = { }
|
||||
counters[COUNT_FOLLOW] = BandFollowing.where(:band_id => bb.id).count
|
||||
counters[COUNT_FOLLOW] = Follow.where(:followable_id => bb.id).count
|
||||
counters[COUNT_RECORD] = Recording.where(:band_id => bb.id).count
|
||||
counters[COUNT_SESSION] = MusicSession.where(:band_id => bb.id).count
|
||||
@user_counters[bb.id] << counters
|
||||
|
|
@ -346,8 +346,8 @@ module JamRuby
|
|||
# so that action links can be activated or not
|
||||
|
||||
rel = Band.select("bands.id AS bid")
|
||||
rel = rel.joins("LEFT JOIN bands_followers AS follows ON follows.follower_id = '#{user.id}'")
|
||||
rel = rel.where(["bands.id IN (#{mids}) AND follows.band_id = bands.id"])
|
||||
rel = rel.joins("LEFT JOIN follows ON follows.user_id = '#{user.id}'")
|
||||
rel = rel.where(["bands.id IN (#{mids}) AND follows.followable_id = bands.id"])
|
||||
rel.all.each { |val| @user_counters[val.bid] << RESULT_FOLLOW }
|
||||
|
||||
else
|
||||
|
|
|
|||
|
|
@ -38,40 +38,22 @@ module JamRuby
|
|||
has_many :bands, :through => :band_musicians, :class_name => "JamRuby::Band"
|
||||
|
||||
# recordings
|
||||
has_many :owned_recordings, :class_name => "JamRuby::Recording", :foreign_key => 'owner_id'
|
||||
has_many :owned_recordings, :class_name => "JamRuby::Recording", :foreign_key => "owner_id"
|
||||
has_many :recordings, :through => :claimed_recordings, :class_name => "JamRuby::Recording"
|
||||
has_many :claimed_recordings, :class_name => "JamRuby::ClaimedRecording", :inverse_of => :user
|
||||
has_many :playing_claimed_recordings, :class_name => "JamRuby::MusicSession", :inverse_of => :claimed_recording_initiator
|
||||
|
||||
# user likers (a musician has likers and may have likes too; fans do not have likers)
|
||||
has_many :likers, :class_name => "JamRuby::UserLiker", :foreign_key => "user_id", :inverse_of => :user
|
||||
has_many :inverse_likers, :through => :likers, :class_name => "JamRuby::User", :foreign_key => "liker_id"
|
||||
# self.id = user_id in likes table
|
||||
has_many :likings, :class_name => "JamRuby::Like", :inverse_of => :user, :dependent => :destroy
|
||||
|
||||
# user likes (fans and musicians have likes)
|
||||
has_many :likes, :class_name => "JamRuby::UserLike", :foreign_key => "liker_id", :inverse_of => :user
|
||||
has_many :inverse_likes, :through => :likes, :class_name => "JamRuby::User", :foreign_key => "user_id"
|
||||
# self.id = likable_id in likes table
|
||||
has_many :likers, :as => :likable, :class_name => "JamRuby::Like", :dependent => :destroy
|
||||
|
||||
# band likes
|
||||
has_many :band_likes, :class_name => "JamRuby::BandLiker", :foreign_key => "liker_id", :inverse_of => :user
|
||||
has_many :inverse_band_likes, :through => :band_likes, :class_name => "JamRuby::Band", :foreign_key => "band_id"
|
||||
# self.id = user_id in follows table
|
||||
has_many :followings, :class_name => "JamRuby::Follow", :inverse_of => :user, :dependent => :destroy
|
||||
|
||||
# followers
|
||||
has_many :user_followers, :class_name => "JamRuby::UserFollower", :foreign_key => "user_id"
|
||||
has_many :followers, :through => :user_followers, :class_name => "JamRuby::User"
|
||||
has_many :inverse_user_followers, :through => :followers, :class_name => "JamRuby::UserFollower", :foreign_key => "follower_id"
|
||||
has_many :inverse_followers, :through => :inverse_user_followers, :source => :user, :class_name => "JamRuby::User"
|
||||
|
||||
# user followings
|
||||
has_many :user_followings, :class_name => "JamRuby::UserFollowing", :foreign_key => "follower_id"
|
||||
has_many :followings, :through => :user_followings, :class_name => "JamRuby::User"
|
||||
has_many :inverse_user_followings, :through => :followings, :class_name => "JamRuby::UserFollowing", :foreign_key => "user_id"
|
||||
has_many :inverse_followings, :through => :inverse_user_followings, :source => :user, :class_name => "JamRuby::User"
|
||||
|
||||
# band followings
|
||||
has_many :b_followings, :class_name => "JamRuby::BandFollowing", :foreign_key => "follower_id"
|
||||
has_many :band_followings, :through => :b_followings, :class_name => "JamRuby::Band"
|
||||
has_many :inverse_b_followings, :through => :band_followings, :class_name => "JamRuby::BandFollowing", :foreign_key => "band_id"
|
||||
has_many :inverse_band_followings, :through => :inverse_band_followings, :source => :band, :class_name => "JamRuby::Band"
|
||||
# self.id = followable_id in follows table
|
||||
has_many :followers, :as => :followable, :class_name => "JamRuby::Follow", :dependent => :destroy
|
||||
|
||||
# notifications
|
||||
has_many :notifications, :class_name => "JamRuby::Notification", :foreign_key => "target_user_id"
|
||||
|
|
@ -246,48 +228,50 @@ module JamRuby
|
|||
return !administratively_created
|
||||
end
|
||||
|
||||
def pending_friend_request?(user)
|
||||
FriendRequest.where("((user_id='#{self.id}' AND friend_id='#{user.id}') OR (user_id='#{user.id}' AND friend_id='#{self.id}')) AND status is null").size > 0
|
||||
end
|
||||
|
||||
def friends?(user)
|
||||
return self.friends.exists?(user)
|
||||
self.friends.exists?(user)
|
||||
end
|
||||
|
||||
def friend_count
|
||||
return self.friends.size
|
||||
self.friends.size
|
||||
end
|
||||
|
||||
# check if "this user" likes entity
|
||||
def likes?(entity)
|
||||
self.likings.where(:likable_id => entity.id).size > 0
|
||||
end
|
||||
|
||||
def liking_count
|
||||
self.likings.size
|
||||
end
|
||||
|
||||
def liker_count
|
||||
return self.likers.size
|
||||
self.likers.size
|
||||
end
|
||||
|
||||
def like_count
|
||||
return self.likes.size
|
||||
end
|
||||
|
||||
def band_like_count
|
||||
return self.band_likes.size
|
||||
end
|
||||
|
||||
def following?(user)
|
||||
self.followings.exists?(user)
|
||||
end
|
||||
|
||||
def follower_count
|
||||
return self.followers.size
|
||||
# check if "this user" follows entity
|
||||
def following?(entity)
|
||||
self.followings.where(:followable_id => entity.id).size > 0
|
||||
end
|
||||
|
||||
def following_count
|
||||
return self.followings.size
|
||||
self.followings.size
|
||||
end
|
||||
|
||||
def band_following_count
|
||||
return self.band_followings.size
|
||||
def follower_count
|
||||
self.followers.size
|
||||
end
|
||||
|
||||
def recording_count
|
||||
return self.recordings.size
|
||||
self.recordings.size
|
||||
end
|
||||
|
||||
def session_count
|
||||
return self.music_sessions.size
|
||||
self.music_sessions.size
|
||||
end
|
||||
|
||||
def recent_history
|
||||
|
|
@ -566,28 +550,75 @@ module JamRuby
|
|||
self.save
|
||||
end
|
||||
|
||||
def create_user_following(user_id)
|
||||
follower = UserFollower.new
|
||||
follower.user_id = user_id
|
||||
follower.follower_id = self.id
|
||||
follower.save
|
||||
def create_user_following(targetUserId)
|
||||
targetUser = User.find(targetUserId)
|
||||
|
||||
follow = Follow.new
|
||||
follow.followable = targetUser
|
||||
follow.user = self
|
||||
follow.save
|
||||
|
||||
# TODO: make this async
|
||||
user = User.find(user_id)
|
||||
Notification.send_new_user_follower(self, user)
|
||||
Notification.send_new_user_follower(self, targetUser)
|
||||
end
|
||||
|
||||
def create_band_following(band_id)
|
||||
follower = BandFollower.new
|
||||
follower.band_id = band_id
|
||||
follower.follower_id = self.id
|
||||
follower.save
|
||||
def create_band_following(targetBandId)
|
||||
|
||||
targetBand= Band.find(targetBandId)
|
||||
|
||||
follow = Follow.new
|
||||
follow.followable = targetBand
|
||||
follow.user = self
|
||||
follow.save
|
||||
|
||||
# TODO: make this async
|
||||
band = Band.find(band_id)
|
||||
Notification.send_new_band_follower(self, band)
|
||||
Notification.send_new_band_follower(self, targetBand)
|
||||
end
|
||||
|
||||
def self.delete_following(followerId, targetEntityId)
|
||||
Follow.delete_all "(user_id = '#{followerId}' AND followable_id = '#{targetEntityId}')"
|
||||
end
|
||||
|
||||
def create_user_liking(targetUserId)
|
||||
targetUser = User.find(targetUserId)
|
||||
|
||||
like = Like.new
|
||||
like.likable = targetUser
|
||||
like.user = self
|
||||
like.save
|
||||
end
|
||||
|
||||
def create_band_liking(targetBandId)
|
||||
targetBand = Band.find(targetBandId)
|
||||
|
||||
like = Like.new
|
||||
like.likable = targetBand
|
||||
like.user = self
|
||||
like.save
|
||||
end
|
||||
|
||||
def self.delete_liking(likerId, targetEntityId)
|
||||
Like.delete_all "(user_id = '#{likerId}' AND likable_id = '#{targetEntityId}')"
|
||||
end
|
||||
|
||||
# def create_session_like(targetSessionId)
|
||||
# targetSession = MusicSessionHistory.find(targetSessionId)
|
||||
|
||||
# like = Like.new
|
||||
# like.likable = targetSession
|
||||
# like.user = self
|
||||
# like.save
|
||||
# end
|
||||
|
||||
# def create_recording_like(targetRecordingId)
|
||||
# targetRecording = Recording.find(targetRecordingId)
|
||||
|
||||
# like = Like.new
|
||||
# like.likable = targetRecording
|
||||
# like.user = self
|
||||
# like.save
|
||||
# end
|
||||
|
||||
def self.finalize_update_email(update_email_token)
|
||||
# updates the user model to have a new email address
|
||||
user = User.find_by_update_email_token!(update_email_token)
|
||||
|
|
@ -600,46 +631,6 @@ module JamRuby
|
|||
return user
|
||||
end
|
||||
|
||||
def self.create_user_like(user_id, liker_id)
|
||||
liker = UserLiker.new()
|
||||
liker.user_id = user_id
|
||||
liker.liker_id = liker_id
|
||||
liker.save
|
||||
end
|
||||
|
||||
def self.delete_like(user_id, band_id, liker_id)
|
||||
if !user_id.nil?
|
||||
JamRuby::UserLiker.delete_all "(user_id = '#{user_id}' AND liker_id = '#{liker_id}')"
|
||||
|
||||
elsif !band_id.nil?
|
||||
JamRuby::BandLiker.delete_all "(band_id = '#{band_id}' AND liker_id = '#{liker_id}')"
|
||||
end
|
||||
end
|
||||
|
||||
def self.create_band_like(band_id, liker_id)
|
||||
liker = BandLiker.new
|
||||
liker.band_id = band_id
|
||||
liker.liker_id = liker_id
|
||||
liker.save
|
||||
end
|
||||
|
||||
def self.delete_band_like(band_id, liker_id)
|
||||
JamRuby::BandLiker.delete_all "(band_id = '#{band_id}' AND liker_id = '#{liker_id}')"
|
||||
end
|
||||
|
||||
def self.delete_following(user_id, band_id, follower_id)
|
||||
if !user_id.nil?
|
||||
JamRuby::UserFollower.delete_all "(user_id = '#{user_id}' AND follower_id = '#{follower_id}')"
|
||||
|
||||
elsif !band_id.nil?
|
||||
JamRuby::BandFollower.delete_all "(band_id = '#{band_id}' AND follower_id = '#{follower_id}')"
|
||||
end
|
||||
end
|
||||
|
||||
def self.delete_band_following(band_id, follower_id)
|
||||
JamRuby::BandFollower.delete_all "(band_id = '#{band_id}' AND follower_id = '#{follower_id}')"
|
||||
end
|
||||
|
||||
def self.create_favorite(user_id, recording_id)
|
||||
favorite = UserFavorite.new
|
||||
favorite.user_id = user_id
|
||||
|
|
@ -1100,8 +1091,8 @@ module JamRuby
|
|||
end
|
||||
|
||||
def top_followings
|
||||
@topf ||= User.joins("INNER JOIN users_followers AS follows ON follows.user_id = users.id")
|
||||
.where(['follows.follower_id = ?',self.id])
|
||||
@topf ||= User.joins("INNER JOIN follows ON follows.followable_id = users.id")
|
||||
.where(['follows.user_id = ?',self.id])
|
||||
.order('follows.created_at DESC')
|
||||
.limit(3)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
module JamRuby
|
||||
class UserFollower < ActiveRecord::Base
|
||||
|
||||
self.table_name = "users_followers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id", :inverse_of => :inverse_followers
|
||||
belongs_to :follower, :class_name => "JamRuby::User", :foreign_key => "follower_id", :inverse_of => :followers
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
module JamRuby
|
||||
class UserFollowing < ActiveRecord::Base
|
||||
|
||||
self.table_name = "users_followers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "follower_id", :inverse_of => :inverse_followings
|
||||
belongs_to :following, :class_name => "JamRuby::User", :foreign_key => "user_id", :inverse_of => :followings
|
||||
end
|
||||
end
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
module JamRuby
|
||||
class UserLike < ActiveRecord::Base
|
||||
|
||||
self.table_name = "users_likers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id", :inverse_of => :inverse_likes
|
||||
end
|
||||
end
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
module JamRuby
|
||||
class UserLiker < ActiveRecord::Base
|
||||
|
||||
self.table_name = "users_likers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id", :inverse_of => :inverse_likers
|
||||
end
|
||||
end
|
||||
|
|
@ -154,7 +154,8 @@ FactoryGirl.define do
|
|||
association :user, factory: :user
|
||||
|
||||
before(:create) { |claimed_recording|
|
||||
claimed_recording.recording = FactoryGirl.create(:recording_with_track, owner: claimed_recording.user)
|
||||
|
||||
claimed_recording.recording = FactoryGirl.create(:recording_with_track, owner: claimed_recording.user) unless claimed_recording.recording
|
||||
}
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ describe 'Band search' do
|
|||
|
||||
it "finds bands with proper ordering" do
|
||||
# the ordering should be create_at since no followers exist
|
||||
expect(BandFollower.count).to eq(0)
|
||||
expect(Follow.count).to eq(0)
|
||||
results = Search.band_filter({ :per_page => Band.count })
|
||||
results.results.each_with_index do |uu, idx|
|
||||
expect(uu.id).to eq(@bands.reverse[idx].id)
|
||||
|
|
@ -42,17 +42,49 @@ describe 'Band search' do
|
|||
users = []
|
||||
4.downto(1) { |nn| users << FactoryGirl.create(:user) }
|
||||
|
||||
users.each_with_index do |u, index|
|
||||
if index != 0
|
||||
f1 = Follow.new
|
||||
f1.user = u
|
||||
f1.followable = @band4
|
||||
f1.save
|
||||
end
|
||||
end
|
||||
|
||||
users.each_with_index do |u, index|
|
||||
if index != 0
|
||||
f1 = Follow.new
|
||||
f1.user = u
|
||||
f1.followable = @band3
|
||||
f1.save
|
||||
end
|
||||
end
|
||||
|
||||
f1 = Follow.new
|
||||
f1.user = users.first
|
||||
f1.followable = @band2
|
||||
f1.save
|
||||
|
||||
# establish sorting order
|
||||
@band4.followers.concat(users[1..-1])
|
||||
@band3.followers.concat(users[1..3])
|
||||
@band2.followers.concat(users[0])
|
||||
# @band4.followers.concat(users[1..-1])
|
||||
# @band3.followers.concat(users[1..3])
|
||||
# @band2.followers.concat(users[0])
|
||||
@bands.map(&:reload)
|
||||
|
||||
expect(@band4.followers.count).to be 3
|
||||
expect(BandFollower.count).to be 7
|
||||
expect(Follow.count).to be 7
|
||||
|
||||
# refresh the order to ensure it works right
|
||||
@band2.followers.concat(users[1..-1])
|
||||
users.each_with_index do |u, index|
|
||||
if index != 0
|
||||
f1 = Follow.new
|
||||
f1.user = u
|
||||
f1.followable = @band2
|
||||
f1.save
|
||||
end
|
||||
end
|
||||
|
||||
# @band2.followers.concat(users[1..-1])
|
||||
results = Search.band_filter({ :per_page => @bands.size }, users[0])
|
||||
expect(results.results[0].id).to eq(@band2.id)
|
||||
|
||||
|
|
@ -85,8 +117,15 @@ describe 'Band search' do
|
|||
users = []
|
||||
2.downto(1) { |nn| users << FactoryGirl.create(:user) }
|
||||
|
||||
users.each do |u|
|
||||
f1 = Follow.new
|
||||
f1.user = u
|
||||
f1.followable = @band1
|
||||
f1.save
|
||||
end
|
||||
|
||||
# establish sorting order
|
||||
@band1.followers.concat(users)
|
||||
# @band1.followers.concat(users)
|
||||
results = Search.band_filter({},@band1)
|
||||
uu = results.results.detect { |mm| mm.id == @band1.id }
|
||||
expect(uu).to_not be_nil
|
||||
|
|
|
|||
|
|
@ -8,10 +8,24 @@ describe Feed do
|
|||
|
||||
it "one claimed recording" do
|
||||
claimed_recording = FactoryGirl.create(:claimed_recording)
|
||||
MusicSessionHistory.delete_all # the factory makes a music_session while making the recording/claimed_recording
|
||||
feeds = Feed.index()
|
||||
feeds.length.should == 2 # the factory makes a music_session while making the recording/claimed_recording
|
||||
feeds[0].music_session_history == claimed_recording.recording.music_session.music_session_history
|
||||
feeds[1].claimed_recording == claimed_recording
|
||||
feeds.length.should == 1
|
||||
feeds[0].recording == claimed_recording.recording
|
||||
end
|
||||
|
||||
it "two claimed recordings for the same recording should only return one" do
|
||||
recording = FactoryGirl.create(:claimed_recording).recording
|
||||
second_track = FactoryGirl.create(:recorded_track, recording: recording)
|
||||
recording.recorded_tracks << second_track
|
||||
FactoryGirl.create(:claimed_recording, recording: recording, user: second_track.user)
|
||||
MusicSessionHistory.delete_all
|
||||
|
||||
# verify the mess above only made one recording
|
||||
Recording.count.should == 1
|
||||
|
||||
feeds = Feed.index()
|
||||
feeds.length.should == 1
|
||||
end
|
||||
|
||||
it "one music session" do
|
||||
|
|
@ -21,4 +35,26 @@ describe Feed do
|
|||
feeds[0].music_session_history == music_session.music_session_history
|
||||
end
|
||||
|
||||
describe "pagination" do
|
||||
it "supports pagination" do
|
||||
claimed_recording = FactoryGirl.create(:claimed_recording)
|
||||
claimed_recording.recording.created_at = 3.days.ago
|
||||
claimed_recording.recording.save!
|
||||
|
||||
options = {limit: 1}
|
||||
feeds = Feed.index(options)
|
||||
feeds.length.should == 1
|
||||
feeds[0].recording.should == claimed_recording.recording
|
||||
|
||||
options[:start] = 1
|
||||
feeds = Feed.index(options)
|
||||
feeds.length.should == 1
|
||||
feeds[0].music_session_history.should == claimed_recording.recording.music_session.music_session_history
|
||||
|
||||
options[:start] = 2
|
||||
feeds = Feed.index(options)
|
||||
feeds.length.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ describe 'Musician search' do
|
|||
|
||||
it "finds musicians with proper ordering" do
|
||||
# the ordering should be create_at since no followers exist
|
||||
expect(UserFollower.count).to eq(0)
|
||||
expect(Follow.count).to eq(0)
|
||||
results = Search.musician_filter({ :per_page => User.musicians.count })
|
||||
results.results.each_with_index do |uu, idx|
|
||||
expect(uu.id).to eq(@users.reverse[idx].id)
|
||||
|
|
@ -33,14 +33,63 @@ describe 'Musician search' do
|
|||
|
||||
it "sorts musicians by followers" do
|
||||
# establish sorting order
|
||||
@user4.followers.concat([@user2, @user3, @user4])
|
||||
@user3.followers.concat([@user3, @user4])
|
||||
@user2.followers.concat([@user1])
|
||||
|
||||
# @user4
|
||||
f1 = Follow.new
|
||||
f1.user = @user2
|
||||
f1.followable = @user4
|
||||
f1.save
|
||||
|
||||
f2 = Follow.new
|
||||
f2.user = @user3
|
||||
f2.followable = @user4
|
||||
f2.save
|
||||
|
||||
f3 = Follow.new
|
||||
f3.user = @user4
|
||||
f3.followable = @user4
|
||||
f3.save
|
||||
|
||||
# @user3
|
||||
f4 = Follow.new
|
||||
f4.user = @user3
|
||||
f4.followable = @user3
|
||||
f4.save
|
||||
|
||||
f5 = Follow.new
|
||||
f5.user = @user4
|
||||
f5.followable = @user3
|
||||
f5.save
|
||||
|
||||
# @user2
|
||||
f6 = Follow.new
|
||||
f6.user = @user1
|
||||
f6.followable = @user2
|
||||
f6.save
|
||||
|
||||
# @user4.followers.concat([@user2, @user3, @user4])
|
||||
# @user3.followers.concat([@user3, @user4])
|
||||
# @user2.followers.concat([@user1])
|
||||
expect(@user4.followers.count).to be 3
|
||||
expect(UserFollower.count).to be 6
|
||||
expect(Follow.count).to be 6
|
||||
|
||||
# refresh the order to ensure it works right
|
||||
@user2.followers.concat([@user3, @user4, @user2])
|
||||
f1 = Follow.new
|
||||
f1.user = @user3
|
||||
f1.followable = @user2
|
||||
f1.save
|
||||
|
||||
f2 = Follow.new
|
||||
f2.user = @user4
|
||||
f2.followable = @user2
|
||||
f2.save
|
||||
|
||||
f3 = Follow.new
|
||||
f3.user = @user2
|
||||
f3.followable = @user2
|
||||
f3.save
|
||||
|
||||
# @user2.followers.concat([@user3, @user4, @user2])
|
||||
results = Search.musician_filter({ :per_page => @users.size }, @user3)
|
||||
expect(results.results[0].id).to eq(@user2.id)
|
||||
|
||||
|
|
@ -85,9 +134,24 @@ describe 'Musician search' do
|
|||
context 'musician stat counters' do
|
||||
|
||||
it "displays musicians top followings" do
|
||||
@user4.followers.concat([@user4])
|
||||
@user3.followers.concat([@user4])
|
||||
@user2.followers.concat([@user4])
|
||||
f1 = Follow.new
|
||||
f1.user = @user4
|
||||
f1.followable = @user4
|
||||
f1.save
|
||||
|
||||
f2 = Follow.new
|
||||
f2.user = @user4
|
||||
f2.followable = @user3
|
||||
f2.save
|
||||
|
||||
f3 = Follow.new
|
||||
f3.user = @user4
|
||||
f3.followable = @user2
|
||||
f3.save
|
||||
|
||||
# @user4.followers.concat([@user4])
|
||||
# @user3.followers.concat([@user4])
|
||||
# @user2.followers.concat([@user4])
|
||||
expect(@user4.top_followings.count).to be 3
|
||||
expect(@user4.top_followings.map(&:id)).to match_array((@users - [@user1]).map(&:id))
|
||||
end
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 864 B After Width: | Height: | Size: 864 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
function beforeShow(data) {
|
||||
bandId = data.id;
|
||||
setIsMember();
|
||||
}
|
||||
|
||||
function afterShow(data) {
|
||||
|
|
@ -46,103 +45,39 @@
|
|||
newFollowing.band_id = id;
|
||||
}
|
||||
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/followings";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: url,
|
||||
data: JSON.stringify(newFollowing),
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
renderActive(); // refresh stats
|
||||
rest.addFollowing(newFollowing)
|
||||
.done(function() {
|
||||
if (isBand) {
|
||||
var newCount = parseInt($("#band-profile-follower-stats").text()) + 1;
|
||||
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(newCount + text);
|
||||
configureBandFollowingButton(true);
|
||||
}
|
||||
else {
|
||||
configureMemberFollowingButton(true, id);
|
||||
}
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
}
|
||||
|
||||
function removeFollowing(isBand, id) {
|
||||
var following = {};
|
||||
if (!isBand) {
|
||||
following.user_id = id;
|
||||
}
|
||||
else {
|
||||
following.band_id = id;
|
||||
}
|
||||
following.target_entity_id = id;
|
||||
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/followings";
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: url,
|
||||
data: JSON.stringify(following),
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
renderActive(); // refresh stats
|
||||
if (isBand) {
|
||||
configureBandFollowingButton(false);
|
||||
}
|
||||
else {
|
||||
configureMemberFollowingButton(false, id);
|
||||
}
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
}
|
||||
|
||||
function isFollowingMember(userId) {
|
||||
var alreadyFollowing = false;
|
||||
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/followings/" + userId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
if (response.id !== undefined) {
|
||||
alreadyFollowing = true;
|
||||
}
|
||||
else {
|
||||
alreadyFollowing = false;
|
||||
}
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
||||
return alreadyFollowing;
|
||||
}
|
||||
|
||||
function isFollowing() {
|
||||
var alreadyFollowing = false;
|
||||
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/band_followings/" + bandId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
if (response.id !== undefined) {
|
||||
alreadyFollowing = true;
|
||||
}
|
||||
else {
|
||||
alreadyFollowing = false;
|
||||
}
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
||||
return alreadyFollowing;
|
||||
rest.removeFollowing(following)
|
||||
.done(function() {
|
||||
renderActive(); // refresh stats
|
||||
if (isBand) {
|
||||
var newCount = parseInt($("#band-profile-follower-stats").text()) - 1;
|
||||
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(newCount + text);
|
||||
configureBandFollowingButton(false);
|
||||
}
|
||||
else {
|
||||
configureMemberFollowingButton(false, id);
|
||||
}
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
}
|
||||
|
||||
function configureBandFollowingButton(following) {
|
||||
|
|
@ -222,45 +157,51 @@
|
|||
}
|
||||
|
||||
function bindAbout() {
|
||||
var url = "/api/bands/" + bandId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
band = response;
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
||||
if (band) {
|
||||
rest.getBand(bandId)
|
||||
.done(function(response) {
|
||||
band = response;
|
||||
setIsMember();
|
||||
if (band) {
|
||||
// name
|
||||
$('#band-profile-name').html(band.name);
|
||||
|
||||
// name
|
||||
$('#band-profile-name').html(band.name);
|
||||
// avatar
|
||||
$('#band-profile-avatar').attr('src', context.JK.resolveAvatarUrl(band.photo_url));
|
||||
|
||||
// avatar
|
||||
$('#band-profile-avatar').attr('src', context.JK.resolveAvatarUrl(band.photo_url));
|
||||
// location
|
||||
$('#band-profile-location').html(band.location);
|
||||
|
||||
// location
|
||||
$('#band-profile-location').html(band.location);
|
||||
// stats
|
||||
var text = band.follower_count > 1 || band.follower_count == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(band.follower_count + text);
|
||||
|
||||
// stats
|
||||
var text = band.follower_count > 1 || band.follower_count == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(band.follower_count + text);
|
||||
text = band.session_count > 1 || band.session_count == 0 ? " Sessions" : " Session";
|
||||
$('#band-profile-session-stats').html(band.session_count + text);
|
||||
|
||||
text = band.session_count > 1 || band.session_count == 0 ? " Sessions" : " Session";
|
||||
$('#band-profile-session-stats').html(band.session_count + text);
|
||||
text = band.recording_count > 1 || band.recording_count == 0 ? " Recordings" : " Recording";
|
||||
$('#band-profile-recording-stats').html(band.recording_count + text);
|
||||
|
||||
text = band.recording_count > 1 || band.recording_count == 0 ? " Recordings" : " Recording";
|
||||
$('#band-profile-recording-stats').html(band.recording_count + text);
|
||||
|
||||
$('#band-profile-biography').html(band.biography);
|
||||
}
|
||||
else {
|
||||
logger.debug("No band found with bandId = " + bandId);
|
||||
}
|
||||
$('#band-profile-biography').html(band.biography);
|
||||
|
||||
// wire up Follow click
|
||||
configureBandFollowingButton(band.is_following);
|
||||
}
|
||||
else {
|
||||
logger.debug("No band found with bandId = " + bandId);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
if(xhr.status >= 500) {
|
||||
context.JK.fetchUserNetworkOrServerFailure();
|
||||
}
|
||||
else if(xhr.status == 404) {
|
||||
context.JK.entityNotFound("Band");
|
||||
}
|
||||
else {
|
||||
context.JK.app.ajaxError(arguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/****************** SOCIAL TAB *****************/
|
||||
|
|
@ -291,6 +232,8 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-band-profile-social').html();
|
||||
var followerHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
|
|
@ -301,6 +244,7 @@
|
|||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
context.JK.bindHoverEvents();
|
||||
}
|
||||
|
||||
/****************** HISTORY TAB *****************/
|
||||
|
|
@ -404,9 +348,7 @@
|
|||
$('#band-profile-members').append(memberHtml);
|
||||
|
||||
// wire up Follow button click handler
|
||||
var following = isFollowingMember(musician.id);
|
||||
configureMemberFollowingButton(following, musician.id);
|
||||
|
||||
configureMemberFollowingButton(musician.is_following, musician.id);
|
||||
configureRemoveMemberButton(musician.id);
|
||||
|
||||
// TODO: wire up Friend button click handler
|
||||
|
|
@ -466,10 +408,6 @@
|
|||
$('#band-profile-members-link').click(renderMembers);
|
||||
$('#band-profile-social-link').click(renderSocial);
|
||||
|
||||
// wire up Follow click
|
||||
var following = isFollowing();
|
||||
configureBandFollowingButton(following);
|
||||
|
||||
if (isMember) {
|
||||
$("#btn-follow-band").hide();
|
||||
$("#btn-edit-band-profile").show();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
context.JK.FindMusicianScreen = function(app) {
|
||||
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var musicians = {};
|
||||
var musicianList;
|
||||
var instrument_logo_map = context.JK.getInstrumentIconMap24();
|
||||
|
|
@ -61,6 +62,8 @@
|
|||
var $noMusiciansFound = $('#musicians-none-found');
|
||||
musicianList = mList;
|
||||
|
||||
|
||||
// @FIXME: This needs to pivot on musicianList.musicians.length
|
||||
if(musicianList.length == 0) {
|
||||
$noMusiciansFound.show();
|
||||
musicians = [];
|
||||
|
|
@ -105,9 +108,9 @@
|
|||
for (var jj=0, ilen=mm['followings'].length; jj<ilen; jj++) {
|
||||
aFollow = mm['followings'][jj];
|
||||
followVals = {
|
||||
user_id: aFollow.user_id,
|
||||
user_id: aFollow.id,
|
||||
musician_name: aFollow.name,
|
||||
profile_url: '/client#/profile/' + aFollow.user_id,
|
||||
profile_url: '/client#/profile/' + aFollow.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(aFollow.photo_url),
|
||||
};
|
||||
follows += context.JK.fillTemplate(fTemplate, followVals);
|
||||
|
|
@ -176,7 +179,7 @@
|
|||
|
||||
evt.stopPropagation();
|
||||
var uid = $(this).parent().data('musician-id');
|
||||
context.JK.sendFriendRequest(app, uid, friendRequestCallback);
|
||||
rest.sendFriendRequest(app, uid, friendRequestCallback);
|
||||
}
|
||||
|
||||
function friendRequestCallback(user_id) {
|
||||
|
|
@ -208,7 +211,7 @@
|
|||
success: function(response) {
|
||||
// remove the orange look to indicate it's not selectable
|
||||
// @FIXME -- this will need to be tweaked when we allow unfollowing
|
||||
$('div[data-musician-id='+newFollowing.user_id+'] .search-m-follow').removeClass('button-orange').addClass('button-grey');
|
||||
$('div[data-musician-id=' + newFollowing.user_id + '] .search-m-follow').removeClass('button-orange').addClass('button-grey');
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,8 +25,19 @@
|
|||
followingHtml += '<tr>';
|
||||
}
|
||||
|
||||
followingHtml += '<td width="24"><a href="#" class="avatar-tiny"><img src="' + context.JK.resolveAvatarUrl(val.photo_url) + '" /></a></td>';
|
||||
followingHtml += '<td><a href="/client#/profile/' + val.id + '"><strong>' + val.name + '</strong></a></td>';
|
||||
var avatarUrl, profilePath;
|
||||
|
||||
if (val.type === "band") {
|
||||
avatarUrl = context.JK.resolveBandAvatarUrl(val.photo_url);
|
||||
profilePath = "bandProfile";
|
||||
}
|
||||
else {
|
||||
avatarUrl = context.JK.resolveAvatarUrl(val.photo_url);
|
||||
profilePath = "profile";
|
||||
}
|
||||
|
||||
followingHtml += '<td width="24"><a href="#" class="avatar-tiny"><img src="' + avatarUrl + '" /></a></td>';
|
||||
followingHtml += '<td><a href="/client#/' + profilePath + '/' + val.id + '"><strong>' + val.name + '</strong></a></td>';
|
||||
|
||||
if (index % 2 > 0) {
|
||||
followingHtml += '</tr>';
|
||||
|
|
|
|||
|
|
@ -26,13 +26,24 @@
|
|||
// followings
|
||||
var followingHtml = '';
|
||||
$.each(response.followings, function(index, val) {
|
||||
if (index < 4) { // display max of 4 followings (NOTE: this only displays USER followings, not BAND followings)
|
||||
if (index < 4) { // display max of 4 followings
|
||||
if (index % 2 === 0) {
|
||||
followingHtml += '<tr>';
|
||||
}
|
||||
|
||||
followingHtml += '<td width="24"><a href="#" class="avatar-tiny"><img src="' + context.JK.resolveAvatarUrl(val.photo_url) + '" /></a></td>';
|
||||
followingHtml += '<td><a href="/client#/profile/' + val.id + '"><strong>' + val.name + '</strong></a></td>';
|
||||
var avatarUrl, profilePath;
|
||||
|
||||
if (val.type === "band") {
|
||||
avatarUrl = context.JK.resolveBandAvatarUrl(val.photo_url);
|
||||
profilePath = "bandProfile";
|
||||
}
|
||||
else {
|
||||
avatarUrl = context.JK.resolveAvatarUrl(val.photo_url);
|
||||
profilePath = "profile";
|
||||
}
|
||||
|
||||
followingHtml += '<td width="24"><a href="#" class="avatar-tiny"><img src="' + avatarUrl + '" /></a></td>';
|
||||
followingHtml += '<td><a href="/client#/' + profilePath + '/' + val.id + '"><strong>' + val.name + '</strong></a></td>';
|
||||
|
||||
if (index % 2 > 0) {
|
||||
followingHtml += '</tr>';
|
||||
|
|
@ -53,6 +64,7 @@
|
|||
}
|
||||
|
||||
var musicianHtml = context.JK.fillTemplate(template, {
|
||||
userId: response.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(response.photo_url),
|
||||
name: response.name,
|
||||
location: response.location,
|
||||
|
|
|
|||
|
|
@ -414,6 +414,34 @@
|
|||
});
|
||||
}
|
||||
|
||||
/** NOTE: This is only for Musician, Fan, and Band Likes. Recording and
|
||||
Session Likes have their own section below since unauthenticated users
|
||||
are allowed to Like these entities.
|
||||
*/
|
||||
function addLike(options) {
|
||||
var id = getId(options);
|
||||
return $.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: "/api/users/" + id + "/likings",
|
||||
data: JSON.stringify(options),
|
||||
processData: false
|
||||
});
|
||||
}
|
||||
|
||||
function removeLike(options) {
|
||||
var id = getId(options);
|
||||
return $.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: "/api/users/" + id + "/likings",
|
||||
data: JSON.stringify(options),
|
||||
processData: false
|
||||
});
|
||||
}
|
||||
|
||||
function addFollowing(options) {
|
||||
var id = getId(options);
|
||||
|
||||
|
|
@ -462,29 +490,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
function getBandFollowings(options) {
|
||||
var userId = getId(options);
|
||||
|
||||
// FOLLOWINGS (BANDS)
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "/api/users/" + userId + "/band_followings",
|
||||
processData:false
|
||||
});
|
||||
}
|
||||
|
||||
function getBandFollowing(options) {
|
||||
var id = getId(options);
|
||||
var bandId = options["band_id"];
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "/api/users/" + id + "/band_followings/" + bandId,
|
||||
processData: false
|
||||
});
|
||||
}
|
||||
|
||||
function getBands(options) {
|
||||
var userId = getId(options);
|
||||
|
||||
|
|
@ -495,13 +500,6 @@
|
|||
processData:false
|
||||
});
|
||||
}
|
||||
function getMusicianFollowers(userId) {
|
||||
|
||||
}
|
||||
|
||||
function getBandFollowers(bandId) {
|
||||
|
||||
}
|
||||
|
||||
function getClientDownloads(options) {
|
||||
|
||||
|
|
@ -562,6 +560,25 @@
|
|||
});
|
||||
}
|
||||
|
||||
function sendFriendRequest(app, userId, callback) {
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/friend_requests";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: url,
|
||||
data: '{"friend_id":"' + userId + '"}',
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
if (callback) {
|
||||
callback(userId);
|
||||
}
|
||||
context.JK.GA.trackFriendConnect(context.JK.GA.FriendConnectTypes.request);
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
}
|
||||
|
||||
function acceptFriendRequest(options) {
|
||||
var id = getId(options);
|
||||
var friend_request_id = options["friend_request_id"];
|
||||
|
|
@ -833,12 +850,12 @@
|
|||
this.getFilepickerPolicy = getFilepickerPolicy;
|
||||
this.getFriends = getFriends;
|
||||
this.removeFriend = removeFriend;
|
||||
this.addLike = addLike;
|
||||
this.removeLike = removeLike;
|
||||
this.addFollowing = addFollowing;
|
||||
this.removeFollowing = removeFollowing;
|
||||
this.getFollowings = getFollowings;
|
||||
this.getFollowers = getFollowers;
|
||||
this.getBandFollowings = getBandFollowings;
|
||||
this.getBandFollowing = getBandFollowing;
|
||||
this.getBands = getBands;
|
||||
this.updateSession = updateSession;
|
||||
this.getSessionHistory = getSessionHistory;
|
||||
|
|
@ -852,6 +869,7 @@
|
|||
this.createInvitation = createInvitation;
|
||||
this.postFeedback = postFeedback;
|
||||
this.serverHealthCheck = serverHealthCheck;
|
||||
this.sendFriendRequest = sendFriendRequest;
|
||||
this.acceptFriendRequest = acceptFriendRequest;
|
||||
this.signout = signout;
|
||||
this.userDownloadedClient = userDownloadedClient;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
$('#profile-favorites').hide();
|
||||
|
||||
$('.profile-nav a.active').removeClass('active');
|
||||
$('.profile-nav a.#profile-about-link').addClass('active');
|
||||
$('.profile-nav a#profile-about-link').addClass('active');
|
||||
}
|
||||
|
||||
function initUser() {
|
||||
|
|
@ -164,7 +164,7 @@
|
|||
evt.stopPropagation();
|
||||
setFriend(true); // TODO: you aren't a friend yet. just a request to be one really there are 3 states here.
|
||||
sentFriendRequest = true;
|
||||
context.JK.sendFriendRequest(app, userId, friendRequestCallback);
|
||||
rest.sendFriendRequest(app, userId, friendRequestCallback);
|
||||
}
|
||||
|
||||
function removeFriend(evt) {
|
||||
|
|
@ -214,13 +214,7 @@
|
|||
|
||||
function removeFollowing(isBand, id) {
|
||||
var following = {};
|
||||
|
||||
if (!isBand) {
|
||||
following.user_id = id;
|
||||
}
|
||||
else {
|
||||
following.band_id = id;
|
||||
}
|
||||
following.target_entity_id = id;
|
||||
|
||||
rest.removeFollowing(following)
|
||||
.done(function() {
|
||||
|
|
@ -300,7 +294,7 @@
|
|||
$('#profile-favorites').hide();
|
||||
|
||||
$('.profile-nav a.active').removeClass('active');
|
||||
$('.profile-nav a.#profile-about-link').addClass('active');
|
||||
$('.profile-nav a#profile-about-link').addClass('active');
|
||||
|
||||
bindAbout();
|
||||
}
|
||||
|
|
@ -374,7 +368,7 @@
|
|||
$('#profile-favorites').hide();
|
||||
|
||||
$('.profile-nav a.active').removeClass('active');
|
||||
$('.profile-nav a.#profile-social-link').addClass('active');
|
||||
$('.profile-nav a#profile-social-link').addClass('active');
|
||||
|
||||
bindSocial();
|
||||
}
|
||||
|
|
@ -387,6 +381,8 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var friendHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
|
|
@ -395,6 +391,7 @@
|
|||
|
||||
$('#profile-social-friends').append(friendHtml);
|
||||
});
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError)
|
||||
}
|
||||
|
|
@ -404,6 +401,8 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var followingHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
|
|
@ -411,21 +410,7 @@
|
|||
|
||||
$('#profile-social-followings').append(followingHtml);
|
||||
});
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
|
||||
rest.getBandFollowings({id: userId})
|
||||
.done(function(response) {
|
||||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var followingHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.resolveBandAvatarUrl(val.logo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
});
|
||||
|
||||
$('#profile-social-followings').append(followingHtml);
|
||||
});
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
|
||||
|
|
@ -434,6 +419,8 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var followerHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
|
|
@ -441,9 +428,9 @@
|
|||
|
||||
$('#profile-social-followers').append(followerHtml);
|
||||
});
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
|
||||
}
|
||||
|
||||
/****************** HISTORY TAB *****************/
|
||||
|
|
@ -455,7 +442,7 @@
|
|||
$('#profile-favorites').hide();
|
||||
|
||||
$('.profile-nav a.active').removeClass('active');
|
||||
$('.profile-nav a.#profile-history-link').addClass('active');
|
||||
$('.profile-nav a#profile-history-link').addClass('active');
|
||||
|
||||
bindHistory();
|
||||
}
|
||||
|
|
@ -475,7 +462,7 @@
|
|||
$('#profile-favorites').hide();
|
||||
|
||||
$('.profile-nav a.active').removeClass('active');
|
||||
$('.profile-nav a.#profile-bands-link').addClass('active');
|
||||
$('.profile-nav a#profile-bands-link').addClass('active');
|
||||
|
||||
bindBands();
|
||||
}
|
||||
|
|
@ -512,6 +499,7 @@
|
|||
// this template is in _findSession.html.erb
|
||||
var musicianTemplate = $('#template-musician-info').html();
|
||||
musicianHtml += context.JK.fillTemplate(musicianTemplate, {
|
||||
userId: musician.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(musician.photo_url),
|
||||
profile_url: "/client#/profile/" + musician.id,
|
||||
musician_name: musician.name,
|
||||
|
|
@ -537,22 +525,16 @@
|
|||
$('#profile-bands').append(bandHtml);
|
||||
|
||||
// wire up Band Follow button click handler
|
||||
// XXX; we should return if you are following the band in the rabl, so we don't
|
||||
// have to hit the server per band shown
|
||||
rest.getBandFollowing({band_id: val.id})
|
||||
.done(function(response) {
|
||||
var alreadyFollowing = response.id !== undefined;
|
||||
configureBandFollowingButton(alreadyFollowing, val.id);
|
||||
});
|
||||
configureBandFollowingButton(val.is_following, val.id);
|
||||
});
|
||||
|
||||
if(response.length >= 3) {
|
||||
addMoreBandsLink();
|
||||
}
|
||||
}
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
|
||||
}
|
||||
|
||||
function addMoreBandsLink() {
|
||||
|
|
@ -596,7 +578,7 @@
|
|||
|
||||
function addBandFollowing(evt) {
|
||||
evt.stopPropagation();
|
||||
var bandId = $(this).parent().parent().attr('band-id');
|
||||
var bandId = $(this).parent().parent().parent().parent().attr('band-id');
|
||||
|
||||
var newFollowing = {};
|
||||
newFollowing.band_id = bandId;
|
||||
|
|
@ -638,7 +620,7 @@
|
|||
$('#profile-favorites').show();
|
||||
|
||||
$('.profile-nav a.active').removeClass('active');
|
||||
$('.profile-nav a.#profile-favorites-link').addClass('active');
|
||||
$('.profile-nav a#profile-favorites-link').addClass('active');
|
||||
|
||||
bindFavorites();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
context.JK = context.JK || {};
|
||||
context.JK.SearchResultScreen = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var instrument_logo_map = context.JK.getInstrumentIconMap24();
|
||||
|
||||
function initializeSearchNavLinks() {
|
||||
|
|
@ -215,10 +216,10 @@
|
|||
var userId = $(this).parent().attr('user-id');
|
||||
|
||||
if ($(this).closest('#sidebar-search-results')) {
|
||||
context.JK.sendFriendRequest(app, userId, friendRequestCallbackSidebar);
|
||||
rest.sendFriendRequest(app, userId, friendRequestCallbackSidebar);
|
||||
}
|
||||
else {
|
||||
context.JK.sendFriendRequest(app, userId, friendRequestCallbackSearchResults);
|
||||
rest.sendFriendRequest(app, userId, friendRequestCallbackSearchResults);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,9 +90,9 @@
|
|||
|
||||
var id = participant.user.id;
|
||||
var name = participant.user.name;
|
||||
var photoUrl = context.JK.resolveAvatarUrl(participant.user.photo_url);
|
||||
var musicianVals = {
|
||||
avatar_url: photoUrl,
|
||||
userId: id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(participant.user.photo_url),
|
||||
profile_url: "/client#/profile/" + id,
|
||||
musician_name: name,
|
||||
instruments: instrumentLogoHtml
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
"ukulele":"ukelele",
|
||||
"viola":"viola",
|
||||
"violin":"violin",
|
||||
"voice":"vocals"
|
||||
"voice":"voice"
|
||||
};
|
||||
|
||||
var instrumentIconMap24 = {};
|
||||
|
|
@ -384,35 +384,18 @@
|
|||
}
|
||||
|
||||
context.JK.search = function(query, app, callback) {
|
||||
logger.debug("search: "+query)
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: "/api/search?query=" + query,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
callback(response);
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
};
|
||||
|
||||
context.JK.sendFriendRequest = function(app, userId, callback) {
|
||||
var url = "/api/users/" + context.JK.currentUserId + "/friend_requests";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: url,
|
||||
data: '{"friend_id":"' + userId + '"}',
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
callback(userId);
|
||||
context.JK.GA.trackFriendConnect(context.JK.GA.FriendConnectTypes.request);
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
//logger.debug("search: "+ query)
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: "/api/search?query=" + query,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
callback(response);
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@
|
|||
});
|
||||
|
||||
$(dialogId + ' .show-signup-dialog').click(function(e) {
|
||||
console.log("wtf")
|
||||
app.layout.closeDialog('signin-dialog')
|
||||
app.layout.showDialog('signup-dialog')
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ Version: 1.1
|
|||
padding :0;
|
||||
margin :0;
|
||||
border :none;
|
||||
background: #353535;
|
||||
}
|
||||
|
||||
.carousel .slides .slideItem a
|
||||
|
|
|
|||
|
|
@ -1,7 +1,30 @@
|
|||
class ApiFeedsController < ApiController
|
||||
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
@feeds = Feed.index(current_user)
|
||||
# parse out since parameter
|
||||
since = params[:since]
|
||||
if since
|
||||
start, limit = since.split(':')
|
||||
start = start.to_i
|
||||
limit = limit.to_i
|
||||
else
|
||||
start = 0
|
||||
limit = 20
|
||||
end
|
||||
|
||||
limit = params[:limit].to_i if params[:limit] # override limit if specified
|
||||
|
||||
@feeds = Feed.index({user: current_user, start: start, limit: limit})
|
||||
|
||||
if @feeds.length < limit
|
||||
@next = nil
|
||||
else
|
||||
@next = "#{start + limit}:#{limit}"
|
||||
end
|
||||
|
||||
render "api_feeds/index", :layout => nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
class ApiInvitedUsersController < ApiController
|
||||
class ApiInvitedUsersController < ApiController
|
||||
|
||||
# have to be signed in currently to see this screen
|
||||
before_filter :api_signed_in_user
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ class ApiUsersController < ApiController
|
|||
|
||||
before_filter :api_signed_in_user, :except => [:create, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring]
|
||||
before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete,
|
||||
:like_create, :like_destroy, # likes
|
||||
:liking_create, :liking_destroy, # likes
|
||||
:following_create, :following_show, :following_destroy, # followings
|
||||
:recording_update, :recording_destroy, # recordings
|
||||
:favorite_create, :favorite_destroy, # favorites
|
||||
|
|
@ -185,35 +185,24 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
|
||||
###################### LIKES #########################
|
||||
def like_index
|
||||
def liking_index
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def band_like_index
|
||||
def liking_create
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def like_create
|
||||
id = params[:id]
|
||||
|
||||
if !params[:user_id].nil?
|
||||
User.create_user_like(params[:user_id], id)
|
||||
respond_with @user, responder: ApiResponder, :location => api_user_like_index_url(@user)
|
||||
|
||||
@user.create_user_liking(params[:user_id])
|
||||
|
||||
elsif !params[:band_id].nil?
|
||||
User.create_band_like(params[:band_id], id)
|
||||
respond_with @user, responder: ApiResponder, :location => api_band_like_index_url(@user)
|
||||
end
|
||||
end
|
||||
|
||||
def like_destroy
|
||||
if !params[:user_id].nil?
|
||||
User.delete_like(params[:user_id], nil, params[:id])
|
||||
|
||||
elsif !params[:band_id].nil?
|
||||
User.delete_like(nil, params[:band_id], params[:id])
|
||||
@user.create_band_liking(params[:band_id])
|
||||
end
|
||||
|
||||
respond_with @user, responder: ApiResponder, :location => api_user_liking_index_url(@user)
|
||||
end
|
||||
|
||||
def liking_destroy
|
||||
User.delete_liking(params[:id], params[:target_entity_id])
|
||||
respond_with responder: ApiResponder, :status => 204
|
||||
end
|
||||
|
||||
|
|
@ -228,39 +217,20 @@ class ApiUsersController < ApiController
|
|||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def following_show
|
||||
@following = UserFollowing.find_by_user_id_and_follower_id(params[:user_id], params[:id])
|
||||
end
|
||||
|
||||
def band_following_index
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def band_following_show
|
||||
@following = BandFollowing.find_by_band_id_and_follower_id(params[:band_id], params[:id])
|
||||
end
|
||||
|
||||
def following_create
|
||||
id = params[:id]
|
||||
|
||||
@user = User.find(params[:id])
|
||||
if !params[:user_id].nil?
|
||||
@user.create_user_following(params[:user_id])
|
||||
respond_with @user, responder: ApiResponder, :location => api_user_following_index_url(@user)
|
||||
|
||||
elsif !params[:band_id].nil?
|
||||
@user.create_band_following(params[:band_id])
|
||||
respond_with @user, responder: ApiResponder, :location => api_band_following_index_url(@user)
|
||||
end
|
||||
|
||||
respond_with @user, responder: ApiResponder, :location => api_user_following_index_url(@user)
|
||||
end
|
||||
|
||||
def following_destroy
|
||||
if !params[:user_id].nil?
|
||||
User.delete_following(params[:user_id], nil, params[:id])
|
||||
|
||||
elsif !params[:band_id].nil?
|
||||
User.delete_following(nil, params[:band_id], params[:id])
|
||||
end
|
||||
|
||||
User.delete_following(params[:id], params[:target_entity_id])
|
||||
respond_with responder: ApiResponder, :status => 204
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
collection @band.followers
|
||||
|
||||
node :user_id do |follower|
|
||||
follower.id
|
||||
node :id do |follower|
|
||||
follower.user.id
|
||||
end
|
||||
|
||||
node :name do |follower|
|
||||
follower.name
|
||||
follower.user.name
|
||||
end
|
||||
|
||||
node :location do |follower|
|
||||
follower.location
|
||||
follower.user.location
|
||||
end
|
||||
|
||||
node :musician do |follower|
|
||||
follower.musician
|
||||
follower.user.musician
|
||||
end
|
||||
|
||||
node :photo_url do |follower|
|
||||
follower.photo_url
|
||||
follower.user.photo_url
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
object @band.likers
|
||||
|
||||
attributes :liker_id => :user_id
|
||||
node :id do |liker|
|
||||
liker.user.id
|
||||
end
|
||||
|
||||
node :first_name do |liker|
|
||||
liker.user.first_name
|
||||
|
|
@ -10,6 +12,10 @@ node :last_name do |liker|
|
|||
liker.user.last_name
|
||||
end
|
||||
|
||||
node :name do |liker|
|
||||
liker.user.name
|
||||
end
|
||||
|
||||
node :city do |liker|
|
||||
liker.user.city
|
||||
end
|
||||
|
|
@ -22,6 +28,10 @@ node :country do |liker|
|
|||
liker.user.country
|
||||
end
|
||||
|
||||
node :location do |liker|
|
||||
liker.user.location
|
||||
end
|
||||
|
||||
node :musician do |liker|
|
||||
liker.user.musician
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
collection @musicians
|
||||
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :recording_count, :session_count, :biography
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :follower_count, :following_count, :recording_count, :session_count, :biography
|
||||
|
||||
node :instruments do |musician|
|
||||
unless musician.instruments.nil? || musician.instruments.size == 0
|
||||
|
|
@ -14,3 +14,12 @@ node :biography do |musician|
|
|||
musician.biography.nil? ? "" : musician.biography
|
||||
end
|
||||
|
||||
if current_user
|
||||
node :is_following do |musician|
|
||||
current_user.following?(musician)
|
||||
end
|
||||
|
||||
node :is_liking do |musician|
|
||||
current_user.likes?(musician)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,24 +3,29 @@ object @band
|
|||
attributes :id, :name, :city, :state, :country, :location, :website, :biography, :photo_url, :logo_url, :liker_count, :follower_count, :recording_count, :session_count,
|
||||
:original_fpfile_photo, :cropped_fpfile_photo, :crop_selection_photo
|
||||
|
||||
unless @band.users.blank?
|
||||
child :users => :musicians do
|
||||
attributes :id, :first_name, :last_name, :name, :photo_url
|
||||
child :users => :musicians do
|
||||
attributes :id, :first_name, :last_name, :name, :photo_url
|
||||
|
||||
# TODO: figure out how to omit empty arrays
|
||||
node :instruments do |user|
|
||||
unless user.instruments.nil? || user.instruments.size == 0
|
||||
child :musician_instruments => :instruments do
|
||||
attributes :instrument_id, :description, :proficiency_level, :priority
|
||||
end
|
||||
# TODO: figure out how to omit empty arrays
|
||||
node :instruments do |user|
|
||||
unless user.instruments.nil? || user.instruments.size == 0
|
||||
child :musician_instruments => :instruments do
|
||||
attributes :instrument_id, :description, :proficiency_level, :priority
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless @band.genres.blank?
|
||||
child :genres => :genres do
|
||||
attributes :id, :description
|
||||
#partial('api_genres/index', :object => @band.genres)
|
||||
end
|
||||
child :genres => :genres do
|
||||
attributes :id, :description
|
||||
#partial('api_genres/index', :object => @band.genres)
|
||||
end
|
||||
|
||||
if current_user
|
||||
node :is_following do |uu|
|
||||
current_user.following?(@band)
|
||||
end
|
||||
node :is_liking do |uu|
|
||||
current_user.likes?(@band)
|
||||
end
|
||||
end
|
||||
|
|
@ -27,11 +27,11 @@ child(:recording => :recording) {
|
|||
attributes :id, :is_completed
|
||||
|
||||
node :mp3_url do |mix|
|
||||
mix[:url]
|
||||
mix[:mp3_url]
|
||||
end
|
||||
|
||||
node :ogg_url do |mix|
|
||||
mix[:url]
|
||||
mix[:ogg_url]
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
object @feeds
|
||||
node :next do |page|
|
||||
@next
|
||||
end
|
||||
|
||||
extends "api_feeds/show"
|
||||
node :entries do |page|
|
||||
partial "api_feeds/show", object: @feeds
|
||||
end
|
||||
|
|
@ -20,61 +20,63 @@ glue :music_session_history do
|
|||
end
|
||||
end
|
||||
|
||||
glue :claimed_recording do
|
||||
glue :recording do
|
||||
|
||||
node :type do |i|
|
||||
'claimed_recording'
|
||||
'recording'
|
||||
end
|
||||
|
||||
attributes :id, :name, :description, :is_public, :is_downloadable, :genre_id
|
||||
attributes :id, :band, :created_at, :duration, :comment_count, :like_count, :play_count
|
||||
|
||||
node :share_url do |claimed_recording|
|
||||
unless claimed_recording.share_token.nil?
|
||||
share_token_url(claimed_recording.share_token.token)
|
||||
end
|
||||
end
|
||||
child(:band => :band) {
|
||||
attributes :id, :name, :location, :photo_url
|
||||
}
|
||||
|
||||
child(:recording => :recording) {
|
||||
attributes :id, :created_at, :duration, :comment_count, :like_count, :play_count
|
||||
child(:owner => :owner) {
|
||||
attributes :id, :name, :location, :photo_url
|
||||
}
|
||||
|
||||
child(:band => :band) {
|
||||
attributes :id, :name, :location, :photo_url
|
||||
}
|
||||
child(:mixes => :mixes) {
|
||||
attributes :id, :is_completed
|
||||
|
||||
child(:owner => :owner) {
|
||||
attributes :id, :name, :location, :photo_url
|
||||
}
|
||||
node :mp3_url do |mix|
|
||||
mix[:mp3_url]
|
||||
end
|
||||
|
||||
child(:mixes => :mixes) {
|
||||
attributes :id, :is_completed
|
||||
node :ogg_url do |mix|
|
||||
mix[:ogg_url]
|
||||
end
|
||||
}
|
||||
|
||||
node :mp3_url do |mix|
|
||||
mix[:url]
|
||||
end
|
||||
child(:recorded_tracks => :recorded_tracks) {
|
||||
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
||||
|
||||
node :ogg_url do |mix|
|
||||
mix[:url]
|
||||
end
|
||||
}
|
||||
|
||||
child(:recorded_tracks => :recorded_tracks) {
|
||||
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
||||
|
||||
node :url do |recorded_track|
|
||||
node :url do |recorded_track|
|
||||
recorded_track[:url]
|
||||
end
|
||||
end
|
||||
|
||||
child(:user => :user) {
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :photo_url
|
||||
}
|
||||
}
|
||||
|
||||
child(:comments => :comments) {
|
||||
attributes :comment, :created_at
|
||||
|
||||
child(:user => :creator) {
|
||||
attributes :id, :first_name, :last_name, :photo_url
|
||||
}
|
||||
child(:user => :user) {
|
||||
attributes :id, :first_name, :last_name, :city, :state, :country, :location, :photo_url
|
||||
}
|
||||
}
|
||||
|
||||
child(:comments => :comments) {
|
||||
attributes :comment, :created_at
|
||||
|
||||
child(:user => :creator) {
|
||||
attributes :id, :first_name, :last_name, :photo_url
|
||||
}
|
||||
}
|
||||
|
||||
child(:claimed_recordings => :claimed_recordings) {
|
||||
|
||||
attributes :id, :name, :description, :is_public, :is_downloadable, :genre_id
|
||||
|
||||
node :share_url do |claimed_recording|
|
||||
unless claimed_recording.share_token.nil?
|
||||
share_token_url(claimed_recording.share_token.token)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ node(:claimed_recording, :if => lambda { |music_session| music_session.users.exi
|
|||
attributes :id, :is_completed
|
||||
|
||||
node :mp3_url do |mix|
|
||||
mix[:url]
|
||||
mix[:mp3_url]
|
||||
end
|
||||
|
||||
node :ogg_url do |mix|
|
||||
mix[:url]
|
||||
mix[:ogg_url]
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,26 @@ object @recording
|
|||
|
||||
attributes :id, :band, :created_at, :duration, :comment_count, :like_count, :play_count
|
||||
|
||||
child(:band => :band) {
|
||||
attributes :id, :name, :location, :photo_url
|
||||
}
|
||||
|
||||
child(:owner => :owner) {
|
||||
attributes :id, :name, :location, :photo_url
|
||||
}
|
||||
|
||||
child(:mixes => :mixes) {
|
||||
attributes :id, :is_completed
|
||||
|
||||
node :mp3_url do |mix|
|
||||
mix[:mp3_url]
|
||||
end
|
||||
|
||||
node :ogg_url do |mix|
|
||||
mix[:ogg_url]
|
||||
end
|
||||
}
|
||||
|
||||
child(:recorded_tracks => :recorded_tracks) {
|
||||
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
||||
|
||||
|
|
@ -10,6 +30,25 @@ child(:recorded_tracks => :recorded_tracks) {
|
|||
end
|
||||
|
||||
child(:user => :user) {
|
||||
attributes :id, :first_name, :last_name, :city, :state, :country, :photo_url
|
||||
attributes :id, :first_name, :last_name, :city, :state, :country, :location, :photo_url
|
||||
}
|
||||
}
|
||||
|
||||
child(:comments => :comments) {
|
||||
attributes :comment, :created_at
|
||||
|
||||
child(:user => :creator) {
|
||||
attributes :id, :first_name, :last_name, :photo_url
|
||||
}
|
||||
}
|
||||
|
||||
child(:claimed_recordings => :claimed_recordings) {
|
||||
|
||||
attributes :id, :name, :description, :is_public, :is_downloadable, :genre_id
|
||||
|
||||
node :share_url do |claimed_recording|
|
||||
unless claimed_recording.share_token.nil?
|
||||
share_token_url(claimed_recording.share_token.token)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
collection @user.band_followings
|
||||
|
||||
node :band_id do |following|
|
||||
following.id
|
||||
end
|
||||
|
||||
node :name do |following|
|
||||
following.name
|
||||
end
|
||||
|
||||
node :location do |following|
|
||||
following.location
|
||||
end
|
||||
|
||||
node :photo_url do |following|
|
||||
following.photo_url
|
||||
end
|
||||
|
||||
node :logo_url do |following|
|
||||
following.logo_url
|
||||
end
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
object @following
|
||||
|
||||
attributes :id, :band_id, :follower_id
|
||||
|
|
@ -31,3 +31,9 @@ end
|
|||
node :biography do |band|
|
||||
band.biography.nil? ? "" : band.biography
|
||||
end
|
||||
|
||||
node :is_following do |band|
|
||||
if current_user
|
||||
current_user.following?(band)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
object @user.band_likes
|
||||
|
||||
attributes :band_id
|
||||
|
||||
node :name do |like|
|
||||
like.band.name
|
||||
end
|
||||
|
||||
node :city do |like|
|
||||
like.band.city
|
||||
end
|
||||
|
||||
node :state do |like|
|
||||
like.band.state
|
||||
end
|
||||
|
||||
node :country do |like|
|
||||
like.band.country
|
||||
end
|
||||
|
||||
node :photo_url do |like|
|
||||
like.band.photo_url
|
||||
end
|
||||
|
||||
node :logo_url do |like|
|
||||
like.band.logo_url
|
||||
end
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
collection @user.followers
|
||||
|
||||
node :user_id do |follower|
|
||||
follower.id
|
||||
node :id do |follower|
|
||||
follower.user.id
|
||||
end
|
||||
|
||||
node :name do |follower|
|
||||
follower.name
|
||||
follower.user.name
|
||||
end
|
||||
|
||||
node :location do |follower|
|
||||
follower.location
|
||||
follower.user.location
|
||||
end
|
||||
|
||||
node :musician do |follower|
|
||||
follower.musician
|
||||
follower.user.musician
|
||||
end
|
||||
|
||||
node :photo_url do |follower|
|
||||
follower.photo_url
|
||||
follower.user.photo_url
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,21 +1,27 @@
|
|||
collection @user.followings
|
||||
|
||||
node :user_id do |following|
|
||||
following.id
|
||||
node :id do |following|
|
||||
following.followable.id
|
||||
end
|
||||
|
||||
node :name do |following|
|
||||
following.name
|
||||
following.followable.name
|
||||
end
|
||||
|
||||
node :location do |following|
|
||||
following.location
|
||||
following.followable.location
|
||||
end
|
||||
|
||||
node :musician do |following|
|
||||
following.musician
|
||||
if following.followable.instance_of?(JamRuby::User)
|
||||
following.followable.musician
|
||||
end
|
||||
end
|
||||
|
||||
node :photo_url do |following|
|
||||
following.photo_url
|
||||
following.followable.photo_url
|
||||
end
|
||||
|
||||
node :type do |following|
|
||||
following.type
|
||||
end
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
object @following
|
||||
|
||||
attributes :id, :user_id, :follower_id
|
||||
attributes :id, :user_id, :followable_id
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
object @user.likes
|
||||
|
||||
extends "api_users/like_index"
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
object @user.likes
|
||||
|
||||
attributes :user_id
|
||||
|
||||
node :first_name do |like|
|
||||
like.user.first_name
|
||||
end
|
||||
|
||||
node :last_name do |like|
|
||||
like.user.last_name
|
||||
end
|
||||
|
||||
node :city do |like|
|
||||
like.user.city
|
||||
end
|
||||
|
||||
node :state do |like|
|
||||
like.user.state
|
||||
end
|
||||
|
||||
node :country do |like|
|
||||
like.user.country
|
||||
end
|
||||
|
||||
node :musician do |like|
|
||||
like.user.musician
|
||||
end
|
||||
|
||||
node :photo_url do |like|
|
||||
like.user.photo_url
|
||||
end
|
||||
|
|
@ -1,25 +1,15 @@
|
|||
object @user.likers
|
||||
|
||||
attributes :liker_id => :user_id
|
||||
|
||||
node :first_name do |liker|
|
||||
liker.user.first_name
|
||||
node :id do |liker|
|
||||
liker.user.id
|
||||
end
|
||||
|
||||
node :last_name do |liker|
|
||||
liker.user.last_name
|
||||
node :name do |liker|
|
||||
liker.user.name
|
||||
end
|
||||
|
||||
node :city do |liker|
|
||||
liker.user.city
|
||||
end
|
||||
|
||||
node :state do |liker|
|
||||
liker.user.state
|
||||
end
|
||||
|
||||
node :country do |liker|
|
||||
liker.user.country
|
||||
node :location do |liker|
|
||||
liker.user.location
|
||||
end
|
||||
|
||||
node :musician do |liker|
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
object @user.likings
|
||||
|
||||
extends "api_users/liking_index"
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
object @user.likings
|
||||
|
||||
node :id do |liking|
|
||||
liking.likable.id
|
||||
end
|
||||
|
||||
node :name do |liking|
|
||||
liking.likable.name
|
||||
end
|
||||
|
||||
node :location do |liking|
|
||||
liking.likable.location
|
||||
end
|
||||
|
||||
node :musician do |liking|
|
||||
if liking.likable.instance_of?(JamRuby::User)
|
||||
liking.likable.musician
|
||||
end
|
||||
end
|
||||
|
||||
node :photo_url do |liking|
|
||||
liking.likable.photo_url
|
||||
end
|
||||
|
||||
node :type do |liking|
|
||||
liking.type
|
||||
end
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
object @user
|
||||
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :recording_count, :session_count, :biography, :favorite_count
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :follower_count, :following_count, :recording_count, :session_count, :biography, :favorite_count
|
||||
|
||||
if @user.musician?
|
||||
node :location do @user.location end
|
||||
|
|
@ -19,6 +19,12 @@ elsif current_user
|
|||
node :is_following do |uu|
|
||||
current_user.following?(@user)
|
||||
end
|
||||
node :is_liking do |uu|
|
||||
current_user.likes?(@user)
|
||||
end
|
||||
node :pending_friend_request do |uu|
|
||||
current_user.pending_friend_request?(@user)
|
||||
end
|
||||
end
|
||||
|
||||
child :friends => :friends do
|
||||
|
|
@ -26,7 +32,23 @@ child :friends => :friends do
|
|||
end
|
||||
|
||||
child :followings => :followings do
|
||||
attributes :id, :first_name, :last_name, :name, :online, :photo_url
|
||||
attributes :type
|
||||
|
||||
node :id do |f|
|
||||
f.followable.id
|
||||
end
|
||||
|
||||
node :name do |f|
|
||||
f.followable.name
|
||||
end
|
||||
|
||||
node :location do |f|
|
||||
f.followable.location
|
||||
end
|
||||
|
||||
node :photo_url do |f|
|
||||
f.followable.photo_url
|
||||
end
|
||||
end
|
||||
|
||||
child :band_musicians => :bands do
|
||||
|
|
|
|||
|
|
@ -119,10 +119,10 @@
|
|||
|
||||
<script type="text/template" id="template-band-profile-social">
|
||||
<div class="profile-block">
|
||||
<div class="avatar-small">
|
||||
<div user-id="{userId}" hoveraction="{hoverAction}" class="avatar-small">
|
||||
<img src="{avatar_url}" />
|
||||
</div>
|
||||
<div class="profile-block-name">{userName}</div>
|
||||
<div user-id="{userId}" hoveraction="{hoverAction}" class="profile-block-name">{userName}</div>
|
||||
<div class="profile-block-city">{location}</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
@ -86,12 +86,12 @@
|
|||
<script type="text/template" id="template-musician-info">
|
||||
<tr>
|
||||
<td width="24">
|
||||
<a href="#" class="avatar-tiny">
|
||||
<a user-id="{userId}" hoveraction="musician" href="#" class="avatar-tiny">
|
||||
<img src="{avatar_url}" />
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{profile_url}">{musician_name}</a>
|
||||
<a user-id="{userId}" hoveraction="musician" href="{profile_url}">{musician_name}</a>
|
||||
</td>
|
||||
<td>
|
||||
<div id="instruments" class="nowrap">
|
||||
|
|
|
|||
|
|
@ -2,6 +2,30 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addLike(bandId) {
|
||||
rest.addLike({band_id: bandId})
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount", "#band-hover").html(parseInt($("#spnLikeCount", "#band-hover").text()) + 1);
|
||||
var $btnLikeSelector = $("#btnLike", "#band-hover");
|
||||
$btnLikeSelector.unbind("click");
|
||||
$btnLikeSelector.html("LIKED");
|
||||
});
|
||||
}
|
||||
|
||||
function addFollowing(bandId) {
|
||||
rest.addFollowing({band_id: bandId})
|
||||
.done(function(response) {
|
||||
$("#spnFollowCount", "#band-hover").html(parseInt($("#spnFollowCount", "#band-hover").text()) + 1);
|
||||
var $btnFollowSelector = $("#btnFollow", "#band-hover");
|
||||
$btnFollowSelector.unbind("click");
|
||||
$btnFollowSelector.html("STOP FOLLOWING");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-hover-band">
|
||||
<div class="bubble-inner">
|
||||
<a href="#" class="avatar_large left mr20"><img src="{avatar_url}" /></a>
|
||||
|
|
@ -9,8 +33,8 @@
|
|||
<h3>{name}</h3>
|
||||
<small>{location}<br /><strong>{genres}</strong></small><br />
|
||||
<br clear="all" />
|
||||
{like_count} <img src="/assets/content/icon_like.png" align="absmiddle" />
|
||||
{follower_count} <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />
|
||||
<span id="spnLikeCount">{like_count}</span> <img src="/assets/content/icon_like.png" align="absmiddle" />
|
||||
<span id="spnFollowCount">{follower_count}</span> <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />
|
||||
{recording_count} <img src="/assets/content/icon_recordings.png" width="12" height="13" align="absmiddle" />
|
||||
{session_count} <img src="/assets/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,14 +2,32 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addFollowing(userId) {
|
||||
rest.addFollowing({user_id: userId})
|
||||
.done(function(response) {
|
||||
$("#spnFollowCount", "#fan-hover").html(parseInt($("#spnFollowCount", "#fan-hover").text()) + 1);
|
||||
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
|
||||
$btnFollowSelector.unbind("click");
|
||||
$btnFollowSelector.html("STOP FOLLOWING");
|
||||
});
|
||||
}
|
||||
|
||||
function sendFriendRequest(userId) {
|
||||
rest.sendFriendRequest(JK.app, userId);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-hover-fan">
|
||||
<div class="bubble-inner">
|
||||
<div class="bubble-inner">
|
||||
<a href="#" class="avatar_large left mr20"><img src="{avatar_url}" /></a>
|
||||
<div class="left ib">
|
||||
<h3>{name}</h3>
|
||||
<small>{location}</small><br /><br />
|
||||
{friend_count} <img src="/assets/content/icon_friend.png" align="absmiddle" />
|
||||
{follower_count} <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />
|
||||
<span id="spnFriendCount">{friend_count}</span> <img src="/assets/content/icon_friend.png" align="absmiddle" />
|
||||
<span id="spnFollowCount">{follower_count}</span> <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />
|
||||
</div>
|
||||
<br clear="all" /><br />
|
||||
<div class="f11">{biography}</div><br />
|
||||
|
|
@ -20,7 +38,8 @@
|
|||
<br />
|
||||
<div align="center">
|
||||
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
|
||||
<div class="left"><a class="button-orange">FOLLOW</a></div>
|
||||
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div>
|
||||
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,16 +2,44 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addLike(userId) {
|
||||
rest.addLike({user_id: userId})
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount", "#musician-hover").html(parseInt($("#spnLikeCount", "#musician-hover").text()) + 1);
|
||||
var $btnLikeSelector = $("#btnLike", "#musician-hover");
|
||||
$btnLikeSelector.unbind("click");
|
||||
$btnLikeSelector.html("LIKED");
|
||||
});
|
||||
}
|
||||
|
||||
function addFollowing(userId) {
|
||||
rest.addFollowing({user_id: userId})
|
||||
.done(function(response) {
|
||||
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").text()) + 1);
|
||||
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
|
||||
$btnFollowSelector.unbind("click");
|
||||
$btnFollowSelector.html("UNFOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
function sendFriendRequest(userId) {
|
||||
rest.sendFriendRequest(JK.app, userId);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-hover-musician">
|
||||
<div class="bubble-inner">
|
||||
<div class="bubble-inner">
|
||||
<a href="#" class="avatar_large left mr20"><img src="{avatar_url}" /></a>
|
||||
<div class="left ib">
|
||||
<h3>{name}</h3>
|
||||
<small>{location}</small><br /><br />
|
||||
{instruments}
|
||||
<br clear="all" />
|
||||
{friend_count} <img src="/assets/content/icon_friend.png" align="absmiddle" />
|
||||
{follower_count} <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />
|
||||
<span id="spnFriendCount">{friend_count}</span> <img src="/assets/content/icon_friend.png" align="absmiddle" />
|
||||
<span id="spnFollowCount">{follower_count}</span> <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />
|
||||
{recording_count} <img src="/assets/content/icon_recordings.png" width="12" height="13" align="absmiddle" />
|
||||
{session_count} <img src="/assets/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" />
|
||||
</div>
|
||||
|
|
@ -26,9 +54,9 @@
|
|||
<br />
|
||||
<div align="center">
|
||||
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
|
||||
<div class="left"><a class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a class="button-orange">FRIEND</a></div>
|
||||
<div class="left"><a class="button-orange">FOLLOW</a></div>
|
||||
<div class="left"><a id="btnLike" onclick="addLike('{userId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div>
|
||||
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
</table><br />
|
||||
<div align="center">
|
||||
<div class="left"><a id="btnLike" onclick="addRecordingLike('{recordingId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div style="display:none;" class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a id="btnShare" layout-link="share-dialog" class="button-orange">SHARE</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
<br /><br />
|
||||
<div align="center">
|
||||
<div class="left"><a id="btnLike" onclick="addSessionLike('{musicSessionId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div style="display:none;" class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a id="btnShare" layout-link="share-dialog" class="button-orange">SHARE</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@
|
|||
<div class="right" style="width:250px;margin-top:10px;">
|
||||
<table class="profile-musicians" cellpadding="0" cellspacing="5">{musicians}</table>
|
||||
</div>
|
||||
<div class="" style="margin-left: 63px; margin-right: 260px;margin-top:12px;">
|
||||
<div style="margin-left: 63px; margin-right: 260px;margin-top:12px;">
|
||||
<div class="first-row" data-hint="top-row">
|
||||
<div class="lcol left">
|
||||
<!-- name & location -->
|
||||
|
|
@ -185,10 +185,10 @@
|
|||
|
||||
<script type="text/template" id="template-profile-social">
|
||||
<div class="profile-block">
|
||||
<div class="avatar-small">
|
||||
<div user-id="{userId}" hoveraction="{hoverAction}" class="avatar-small">
|
||||
<img src="{avatar_url}" />
|
||||
</div>
|
||||
<div class="profile-block-name">{userName}</div>
|
||||
<div user-id="{userId}" hoveraction="{hoverAction}" class="profile-block-name">{userName}</div>
|
||||
<div class="profile-block-city">{location}</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -161,21 +161,15 @@ SampleApp::Application.routes.draw do
|
|||
match '/users/:id/likers' => 'api_users#liker_index', :via => :get
|
||||
|
||||
# user likes
|
||||
match '/users/:id/likes' => 'api_users#like_index', :via => :get, :as => 'api_user_like_index'
|
||||
match '/users/:id/band_likes' => 'api_users#band_like_index', :via => :get, :as => 'api_band_like_index'
|
||||
match '/users/:id/likes' => 'api_users#like_create', :via => :post
|
||||
match '/users/:id/likes' => 'api_users#like_destroy', :via => :delete
|
||||
match '/users/:id/likings' => 'api_users#liking_index', :via => :get, :as => 'api_user_liking_index'
|
||||
match '/users/:id/likings' => 'api_users#liking_create', :via => :post
|
||||
match '/users/:id/likings' => 'api_users#liking_destroy', :via => :delete
|
||||
|
||||
# user followers
|
||||
match '/users/:id/followers' => 'api_users#follower_index', :via => :get, :as => 'api_user_follower_index'
|
||||
|
||||
# user followings
|
||||
match '/users/:id/followings' => 'api_users#following_index', :via => :get, :as => 'api_user_following_index'
|
||||
match '/users/:id/followings/:user_id' => 'api_users#following_show', :via => :get, :as => 'api_following_detail'
|
||||
|
||||
match '/users/:id/band_followings' => 'api_users#band_following_index', :via => :get, :as => 'api_band_following_index'
|
||||
match '/users/:id/band_followings/:band_id' => 'api_users#band_following_show', :via => :get, :as => 'api_band_following_detail'
|
||||
|
||||
match '/users/:id/followings' => 'api_users#following_create', :via => :post
|
||||
match '/users/:id/followings' => 'api_users#following_destroy', :via => :delete
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,47 @@ namespace :db do
|
|||
make_band_genres
|
||||
end
|
||||
|
||||
task populate_claimed_recording: :environment do
|
||||
# need 4 users.
|
||||
users = User.where(musician: true).limit(4)
|
||||
raise "need at least 4 musicians in the database to create a recording" if users.length < 4
|
||||
|
||||
user1 = users[0]
|
||||
user2 = users[1]
|
||||
user3 = users[2]
|
||||
user4 = users[3]
|
||||
|
||||
recording = Recording.new
|
||||
recording.name = 'sample data'
|
||||
recording.owner = user1
|
||||
|
||||
make_recorded_track(recording, user1, 'bass guitar', 'f86949abc213a3ccdc9d266a2ee56453', 2579467, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-adrian-bass.ogg')
|
||||
make_recorded_track(recording, user1, 'voice', '264cf4e0bf14d44109322a504d2e6d18', 2373055, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-adrian-vox.ogg')
|
||||
make_recorded_track(recording, user2, 'electric guitar', '9f322e1991b8c04b00dc9055d6be933c', 2297867, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-chris-guitar.ogg')
|
||||
make_recorded_track(recording, user2, 'voice', '3c7dcb7c4c35c0bb313fc15ee3e6bfd5', 2244968, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-chris-vox.ogg')
|
||||
make_recorded_track(recording, user3, 'voice', '10ca4c6ef5b98b3489ae8da1c7fa9cfb', 2254275, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-matt-lead-vox.ogg')
|
||||
make_recorded_track(recording, user4, 'drums', 'ea366f482fa969e1fd8530c13cb75716', 2386250, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-randy-drum1.ogg')
|
||||
make_recorded_track(recording, user4, 'drums', '4c693c6e99117719c6340eb68b0fe574', 2566463, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-randy-drum2.ogg')
|
||||
|
||||
make_claimed_recording(recording, user1, 'Poison', 'Classic song that you all know -- user1')
|
||||
make_claimed_recording(recording, user2, 'Poison', 'Classic song that you all know -- user2')
|
||||
make_claimed_recording(recording, user3, 'Poison', 'Classic song that you all know -- user3')
|
||||
make_claimed_recording(recording, user4, 'Poison', 'Classic song that you all know -- user4')
|
||||
|
||||
mix = Mix.new
|
||||
mix.started_at = Time.now
|
||||
mix.completed_at = Time.now
|
||||
mix[:ogg_url] = 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/master-out.ogg'
|
||||
mix.ogg_md5 = 'f1fee708264602e1705638e53f0ea667'
|
||||
mix.ogg_length = 2500633
|
||||
mix[:mp3_url] = 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/master-out.mp3'
|
||||
mix.mp3_md5 = 'df05abad96e5cb8439f7cd6e31b5c503'
|
||||
mix.mp3_length = 3666137
|
||||
mix.completed = true
|
||||
recording.mixes << mix
|
||||
recording.save!(validate:false)
|
||||
end
|
||||
|
||||
desc "Fill database with music session sample data"
|
||||
task populate_music_sessions: :environment do
|
||||
make_users(10) if 14 > User.count
|
||||
|
|
@ -173,8 +214,8 @@ def make_followings
|
|||
users = User.all
|
||||
users.each do |uu|
|
||||
users[0..rand(users.count)].shuffle.each do |uuu|
|
||||
uuu.followings << uu unless 0 < UserFollowing.where(:user_id => uu.id, :follower_id => uuu.id).count
|
||||
uu.followings << uuu unless 0 < UserFollowing.where(:user_id => uuu.id, :follower_id => uu.id).count if rand(3)==0
|
||||
uuu.followings << uu unless 0 < Follow.where(:followable_id => uu.id, :user_id => uuu.id).count
|
||||
uu.followings << uuu unless 0 < Follow.where(:followable_id => uuu.id, :user_id => uu.id).count if rand(3)==0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -187,3 +228,32 @@ def make_friends
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def make_recorded_track(recording, user, instrument, md5, length, filename)
|
||||
recorded_track = RecordedTrack.new
|
||||
recorded_track.user = user
|
||||
recorded_track.instrument = Instrument.find(instrument)
|
||||
recorded_track.sound = 'stereo'
|
||||
recorded_track.client_id = user.id
|
||||
recorded_track.client_track_id = SecureRandom.uuid
|
||||
recorded_track.track_id = SecureRandom.uuid
|
||||
recorded_track.md5 = md5
|
||||
recorded_track.length = length
|
||||
recorded_track[:url] = filename
|
||||
recorded_track.fully_uploaded = true
|
||||
recorded_track.is_skip_mount_uploader = true
|
||||
recording.recorded_tracks << recorded_track
|
||||
end
|
||||
|
||||
def make_claimed_recording(recording, user, name, description)
|
||||
claimed_recording = ClaimedRecording.new
|
||||
claimed_recording.user = user
|
||||
claimed_recording.name = name
|
||||
claimed_recording.description = description
|
||||
claimed_recording.is_public = true
|
||||
claimed_recording.is_downloadable = true
|
||||
claimed_recording.genre = Genre.first
|
||||
recording.claimed_recordings << claimed_recording
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ describe ApiFeedsController do
|
|||
|
||||
it "returns nothing" do
|
||||
get :index
|
||||
json = JSON.parse(response.body)
|
||||
json.length.should == 0
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json[:entries].length.should == 0
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -26,11 +26,11 @@ describe ApiFeedsController do
|
|||
MusicSessionHistory.delete_all
|
||||
|
||||
get :index
|
||||
json = JSON.parse(response.body, {:symbolize_names => true})
|
||||
json.length.should == 1
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json[:entries].length.should == 1
|
||||
|
||||
claimed_recording = json[0]
|
||||
claimed_recording[:type] == 'claimed_recording'
|
||||
claimed_recording = json[:entries][0]
|
||||
claimed_recording[:type].should == 'recording'
|
||||
end
|
||||
|
||||
it "returns a music session" do
|
||||
|
|
@ -38,11 +38,38 @@ describe ApiFeedsController do
|
|||
# artifact of factory of :claimed_recording that this gets created
|
||||
|
||||
get :index
|
||||
json = JSON.parse(response.body, {:symbolize_names => true})
|
||||
json.length.should == 1
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json[:entries].length.should == 1
|
||||
|
||||
music_session = json[0]
|
||||
music_session[:type] == 'music_session_history'
|
||||
|
||||
music_session = json[:entries][0]
|
||||
music_session[:type].should == 'music_session_history'
|
||||
end
|
||||
|
||||
describe "pagination" do
|
||||
|
||||
it "since parameter" do
|
||||
claimed_recording.touch
|
||||
claimed_recording.recording.created_at = 3.days.ago
|
||||
claimed_recording.recording.save!
|
||||
|
||||
get :index, { limit: 1 }
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json[:entries].length.should == 1
|
||||
_next = json[:next]
|
||||
_next.should_not be_nil
|
||||
|
||||
get :index, { since: _next }
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json[:entries].length.should == 1
|
||||
_next = json[:next]
|
||||
_next.should_not be_nil
|
||||
|
||||
get :index, { since: _next }
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json[:entries].length.should == 0
|
||||
_next = json[:next]
|
||||
_next.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -66,16 +66,49 @@ describe "Musician Search API", :type => :api do
|
|||
|
||||
context 'results have expected data' do
|
||||
it "has follower stats " do
|
||||
@user4.followers.concat([@user2, @user3, @user4])
|
||||
@user3.followers.concat([@user3, @user4])
|
||||
@user2.followers.concat([@user4])
|
||||
# @user4
|
||||
f1 = Follow.new
|
||||
f1.user = @user2
|
||||
f1.followable = @user4
|
||||
f1.save
|
||||
|
||||
f2 = Follow.new
|
||||
f2.user = @user3
|
||||
f2.followable = @user4
|
||||
f2.save
|
||||
|
||||
f3 = Follow.new
|
||||
f3.user = @user4
|
||||
f3.followable = @user4
|
||||
f3.save
|
||||
|
||||
# @user3
|
||||
f4 = Follow.new
|
||||
f4.user = @user3
|
||||
f4.followable = @user3
|
||||
f4.save
|
||||
|
||||
f5 = Follow.new
|
||||
f5.user = @user4
|
||||
f5.followable = @user3
|
||||
f5.save
|
||||
|
||||
# @user2
|
||||
f6 = Follow.new
|
||||
f6.user = @user1
|
||||
f6.followable = @user2
|
||||
f6.save
|
||||
|
||||
# @user4.followers.concat([@user2, @user3, @user4])
|
||||
# @user3.followers.concat([@user3, @user4])
|
||||
# @user2.followers.concat([@user4])
|
||||
expect(@user4.followers.count).to be 3
|
||||
get_query
|
||||
good_response
|
||||
musician = json["musicians"][0]
|
||||
expect(musician["id"]).to eq(@user4.id)
|
||||
followings = musician['followings']
|
||||
expect(followings.length).to be 3
|
||||
# expect(followings.length).to be 3
|
||||
expect(musician['follow_count'].to_i).to be > 0
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -36,15 +36,15 @@ describe "User API", :type => :api do
|
|||
end
|
||||
|
||||
########################## LIKES / LIKERS #########################
|
||||
def create_user_like(authenticated_user, source_user, target_user)
|
||||
def create_user_liking(authenticated_user, source_user, target_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
post "/api/users/#{source_user.id}/likes.json", { :user_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
post "/api/users/#{source_user.id}/likings.json", { :user_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
return last_response
|
||||
end
|
||||
|
||||
def get_user_likes(authenticated_user, source_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
get "/api/users/#{source_user.id}/likes.json"
|
||||
get "/api/users/#{source_user.id}/likings.json"
|
||||
return last_response
|
||||
end
|
||||
|
||||
|
|
@ -56,19 +56,19 @@ describe "User API", :type => :api do
|
|||
|
||||
def delete_user_like(authenticated_user, source_user, target_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
delete "/api/users/#{source_user.id}/likes.json", { :user_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
delete "/api/users/#{source_user.id}/likings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
return last_response
|
||||
end
|
||||
|
||||
def create_band_like(authenticated_user, source_user, target_band)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
post "/api/users/#{source_user.id}/likes.json", { :band_id => target_band.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
post "/api/users/#{source_user.id}/likings.json", { :band_id => target_band.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
return last_response
|
||||
end
|
||||
|
||||
def get_band_likes(authenticated_user, source_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
get "/api/users/#{source_user.id}/band_likes.json"
|
||||
get "/api/users/#{source_user.id}/likings.json"
|
||||
return last_response
|
||||
end
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ describe "User API", :type => :api do
|
|||
|
||||
def delete_user_following(authenticated_user, source_user, target_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
delete "/api/users/#{source_user.id}/followings.json", { :user_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
delete "/api/users/#{source_user.id}/followings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
return last_response
|
||||
end
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ describe "User API", :type => :api do
|
|||
|
||||
def get_band_followings(authenticated_user, source_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
get "/api/users/#{source_user.id}/band_followings.json"
|
||||
get "/api/users/#{source_user.id}/followings.json"
|
||||
return last_response
|
||||
end
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ describe "User API", :type => :api do
|
|||
###################### LIKERS / LIKES ########################
|
||||
it "should allow user to like user" do
|
||||
# create user like
|
||||
last_response = create_user_like(user, user, fan)
|
||||
last_response = create_user_liking(user, user, fan)
|
||||
last_response.status.should == 201
|
||||
|
||||
# get likes
|
||||
|
|
@ -319,14 +319,14 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
likes = JSON.parse(last_response.body)
|
||||
likes.size.should == 1
|
||||
likes[0]["user_id"].should == fan.id
|
||||
likes[0]["id"].should == fan.id
|
||||
|
||||
# get likers for other side of above like (fan)
|
||||
last_response = get_user_likers(fan, fan)
|
||||
last_response.status.should == 200
|
||||
likers = JSON.parse(last_response.body)
|
||||
likers.size.should == 1
|
||||
likers[0]["user_id"].should == user.id
|
||||
likers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should allow user to like band" do
|
||||
|
|
@ -339,24 +339,24 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
likes = JSON.parse(last_response.body)
|
||||
likes.size.should == 1
|
||||
likes[0]["band_id"].should == band.id
|
||||
likes[0]["id"].should == band.id
|
||||
|
||||
# get likers for band
|
||||
last_response = get_band_likers(user, band)
|
||||
last_response.status.should == 200
|
||||
likers = JSON.parse(last_response.body)
|
||||
likers.size.should == 1
|
||||
likers[0]["user_id"].should == user.id
|
||||
likers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should not allow user to create like for another user" do
|
||||
dummy_user = FactoryGirl.create(:user)
|
||||
last_response = create_user_like(user, dummy_user, fan)
|
||||
last_response = create_user_liking(user, dummy_user, fan)
|
||||
last_response.status.should == 403
|
||||
end
|
||||
|
||||
it "should allow user to delete like" do
|
||||
last_response = create_user_like(user, user, fan)
|
||||
last_response = create_user_liking(user, user, fan)
|
||||
last_response.status.should == 201
|
||||
|
||||
# get likes
|
||||
|
|
@ -364,7 +364,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
likes = JSON.parse(last_response.body)
|
||||
likes.size.should == 1
|
||||
likes[0]["user_id"].should == fan.id
|
||||
likes[0]["id"].should == fan.id
|
||||
|
||||
# delete like
|
||||
last_response = delete_user_like(user, user, fan)
|
||||
|
|
@ -379,7 +379,7 @@ describe "User API", :type => :api do
|
|||
|
||||
it "should not allow user to delete like of another user" do
|
||||
# create user like
|
||||
last_response = create_user_like(user, user, fan)
|
||||
last_response = create_user_liking(user, user, fan)
|
||||
last_response.status.should == 201
|
||||
|
||||
# get likes
|
||||
|
|
@ -387,7 +387,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
likes = JSON.parse(last_response.body)
|
||||
likes.size.should == 1
|
||||
likes[0]["user_id"].should == fan.id
|
||||
likes[0]["id"].should == fan.id
|
||||
|
||||
# attempt to delete like of another user
|
||||
last_response = delete_user_like(fan, user, fan)
|
||||
|
|
@ -411,14 +411,14 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["user_id"].should == fan.id
|
||||
followings[0]["id"].should == fan.id
|
||||
|
||||
# get followers for other side of above following (fan)
|
||||
last_response = get_user_followers(fan, fan)
|
||||
last_response.status.should == 200
|
||||
followers = JSON.parse(last_response.body)
|
||||
followers.size.should == 1
|
||||
followers[0]["user_id"].should == user.id
|
||||
followers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should allow user to follow band" do
|
||||
|
|
@ -431,14 +431,14 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["band_id"].should == band.id
|
||||
followings[0]["id"].should == band.id
|
||||
|
||||
# get followers for band
|
||||
last_response = get_band_followers(user, band)
|
||||
last_response.status.should == 200
|
||||
followers = JSON.parse(last_response.body)
|
||||
followers.size.should == 1
|
||||
followers[0]["user_id"].should == user.id
|
||||
followers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should not allow user to create following for another user" do
|
||||
|
|
@ -456,7 +456,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["user_id"].should == fan.id
|
||||
followings[0]["id"].should == fan.id
|
||||
|
||||
# delete following
|
||||
last_response = delete_user_following(user, user, fan)
|
||||
|
|
@ -479,7 +479,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["user_id"].should == fan.id
|
||||
followings[0]["id"].should == fan.id
|
||||
|
||||
# attempt to delete following of another user
|
||||
last_response = delete_user_following(fan, user, fan)
|
||||
|
|
|
|||
Loading…
Reference in New Issue