diff --git a/db/up/find_sessions_2020.sql b/db/up/find_sessions_2020.sql index 8d136bf5c..d426e29cc 100644 --- a/db/up/find_sessions_2020.sql +++ b/db/up/find_sessions_2020.sql @@ -140,4 +140,6 @@ UPDATE users set stored_credit_card = true where recurly_code is not null; -- alreday on WWW CREATE INDEX msuh_user_id ON music_sessions_user_history USING btree (user_id); -CREATE INDEX msuh_created_at ON music_sessions_user_history USING btree (created_at); \ No newline at end of file +CREATE INDEX msuh_created_at ON music_sessions_user_history USING btree (created_at); + +CREATE INDEX bands_musicians_user_id_idx ON bands_musicians USING btree (user_id); \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/feed.rb b/ruby/lib/jam_ruby/models/feed.rb index befdc900a..f4da3cd80 100644 --- a/ruby/lib/jam_ruby/models/feed.rb +++ b/ruby/lib/jam_ruby/models/feed.rb @@ -31,6 +31,11 @@ module JamRuby target_user = params[:user] target_band = params[:band] + # TODO: SPEED UP QUERY. CURRENTLY TAKES FOR EVER. + if target_user or target_band + return { query: [], next_page: nil} + end + #query = Feed.includes([:recording]).includes([:music_session]).limit(limit) query = Feed.joins("LEFT OUTER JOIN recordings ON recordings.id = feeds.recording_id") .joins("LEFT OUTER JOIN music_sessions ON music_sessions.id = feeds.music_session_id") diff --git a/web/app/assets/javascripts/react-components/AccountSubscriptionScreen.js.jsx.coffee b/web/app/assets/javascripts/react-components/AccountSubscriptionScreen.js.jsx.coffee index ec602c3ed..49ecf9920 100644 --- a/web/app/assets/javascripts/react-components/AccountSubscriptionScreen.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/AccountSubscriptionScreen.js.jsx.coffee @@ -18,8 +18,10 @@ profileUtils = context.JK.ProfileUtils Reflux.listenTo(SubscriptionStore, "onSubscriptionChanged") ] + subRef: null + onAppInit: (@app) -> - @app.bindScreen('account/subscription', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide}) + @app.bindScreen('account/subscription', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide, beforeLeave: @beforeLeave}) onUserChanged: (userState) -> @setState({user: userState?.user}) @@ -32,8 +34,44 @@ profileUtils = context.JK.ProfileUtils return true beforeShow: (e) -> + + @allowLeave = false + SubscriptionActions.updateSubscription() + forceUpdate: () -> + this.refs.sub.onSubmit() + + userMustLeave: (location) -> + @allowLeave = true + window.location.href = '/client' + location + + beforeLeave: (data) -> + console.debug("subscription beforeLeave", @allowLeave) + + if !this.refs.sub? || @allowLeave + return true + else + + if this.refs.sub? + if !this.refs.sub.state.selectedPlan? + console.log("no selected plan; can leave") + return true + + buttons = [] + buttons.push({name: 'LEAVE ANYWAY', buttonStyle: 'button-grey', click: (() => (@userMustLeave(data.hash)))}) + buttons.push({ + name: 'UPDATE PLAN', + buttonStyle: 'button-orange', + click: (() => (@forceUpdate())) + }) + context.JK.Banner.show({ + title: "Subscription Not Updated", + html: '
If you leave this page without saving your new subscription plan preference, your selection will not take effect.

To save your new plan, please click the Update Plan button
', + buttons: buttons}) + + return false + afterShow: (e) -> @screenVisible = true logger.debug("AccountSubscriptionScreen: afterShow") @@ -49,7 +87,7 @@ profileUtils = context.JK.ProfileUtils if @state.subscription - currentSubscription = `` + currentSubscription = `` content = `
diff --git a/web/app/assets/javascripts/react-components/CurrentSubscription.js.jsx.coffee b/web/app/assets/javascripts/react-components/CurrentSubscription.js.jsx.coffee index 540bc7a80..18c7fa05f 100644 --- a/web/app/assets/javascripts/react-components/CurrentSubscription.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/CurrentSubscription.js.jsx.coffee @@ -42,6 +42,9 @@ AppStore = context.AppStore else this.props.subscription.desired_plan_code || '' + checkIfPending:() -> + return this.state.selectedPlan? + onSubmit: (event) -> if event event.preventDefault() @@ -75,6 +78,7 @@ AppStore = context.AppStore SubscriptionActions.forceUpdate(subscription) has_billing_info = subscription.has_billing_info console.log("subscription change update", subscription) + @setState({updating: false, selectedPlan: null}) if has_billing_info @props.app.layout.notify({ title: "Subscription updated!", @@ -108,7 +112,7 @@ AppStore = context.AppStore # title: "Payment method still needed", # text: "Please click UPDATE PAYMENT METHOD in the bottom-right of the screen." #}) - @setState({updating: false, selectedPlan: null}) + ) .fail((jqXHR) => @setState({updating: false}) @@ -128,10 +132,6 @@ AppStore = context.AppStore if confirm("Are you sure you want to cancel your plan?") SubscriptionActions.cancelSubscription() - componentDidUpdate: () -> - if @state.updating - @setState({updating:false}) - componentDidMount: () -> @root = $(@getDOMNode()) @@ -164,6 +164,11 @@ AppStore = context.AppStore if !@state.selectedPlan? || @state.updating changeClass = changeClass + ' disabled' + if @state.updating + update_plan_text = 'UPDATING PLAN ... PLEASE WAIT' + else + update_plan_text = 'UPDATE PLAN' + recurly_subscription = @props.subscription.subscription effective_plan_name = `{this.getDisplayNameTier(this.props.subscription.plan_code)}` @@ -177,8 +182,7 @@ AppStore = context.AppStore show_payment_info = null has_billing_info = @props.subscription.has_billing_info - #console.log("@props.subscription.subscription", @props.subscription.subscription, has_pending_subscription) - + if admin_override explanation = `You have a {effective_plan_name} account until your gifted plan ends {context.JK.formatDateShort(this.props.subscription.admin_override_ends_at)}.` else if in_trial @@ -232,7 +236,7 @@ AppStore = context.AppStore
{plansJsx} COMPARE PLANS - +