* update teacher dump admin page and add new URL

This commit is contained in:
Seth Call 2016-03-25 12:08:23 -05:00
parent a82181b63d
commit 12d8310dc6
8 changed files with 54 additions and 6 deletions

View File

@ -7,7 +7,10 @@ ActiveAdmin.register JamRuby::Teacher, :as => 'Teachers' do
config.per_page = 100
config.paginate = true
scope("Default", default: true) { |scope| scope.unscoped.order("background_check_at > '#{(Date.today - 365).to_s}}' NULLS FIRST, ready_for_session_at IS NULL DESC") }
scope("All", default: true) { |scope| scope.unscoped.order("background_check_at > '#{(Date.today - 365).to_s}}' NULLS FIRST, ready_for_session_at IS NULL DESC") }
scope("All Sorted By Sign Up") { |scope| scope.unscoped.order("teachers.created_at DESC, background_check_at > '#{(Date.today - 365).to_s}}' NULLS FIRST, ready_for_session_at IS NULL DESC") }
scope("50% and Session Ready" ) { |scope| scope.unscoped.where('profile_pct >= ?', 50.0).where('ready_for_session_at IS NOT NULL').order("background_check_at > '#{(Date.today - 365).to_s}}' NULLS FIRST, ready_for_session_at IS NULL DESC") }
scope("50% and Not Session Ready" ) { |scope| scope.unscoped.where('profile_pct > ?', 50.0).where('ready_for_session_at IS NULL').order("background_check_at > '#{(Date.today - 365).to_s}}' NULLS FIRST, ready_for_session_at IS NULL DESC") }
index do
column "Name" do |teacher|
@ -67,11 +70,8 @@ ActiveAdmin.register JamRuby::Teacher, :as => 'Teachers' do
link_to("mark as checked", mark_background_check_admin_teacher_path(teacher.id), {confirm: "Mark as background checked?"})
end
end
end
end
column "Session Ready" do |teacher|
div do
if teacher.ready_for_session_at
@ -118,6 +118,10 @@ ActiveAdmin.register JamRuby::Teacher, :as => 'Teachers' do
end
end
column "Signed Up" do |teacher|
teacher.created_at.to_date
end
end
show do
@ -238,6 +242,11 @@ ActiveAdmin.register JamRuby::Teacher, :as => 'Teachers' do
end
end
row "Signed Up" do |teacher|
teacher.created_at.to_date
end
end
end

View File

@ -21,4 +21,19 @@ class EmailController < ApplicationController
@users = @users.select('DISTINCT users.id, email, first_name, last_name').joins(:sales => :sale_line_items).where("sale_line_items.product_type = 'JamTrack'")
end
end
def dump_teachers
if params[:code] != Rails.application.config.email_dump_code
render :text => "", :status => 404
return
end
headers['Content-Disposition'] = "attachment; filename=\"teacher-list.csv\""
headers['Content-Type'] ||= 'text/csv'
@users = User.joins(:teacher)
render "dump_emailables.csv.erb"
end
end

View File

@ -30,6 +30,7 @@ JamAdmin::Application.routes.draw do
match '/api/checks/latency_tester' => 'checks#check_latency_tester', :via => :get
match '/api/users/emailables/:code' => 'email#dump_emailables', :via => :get
match '/api/teachers/:code' => 'email#dump_teachers', :via => :get
match '/jam_tracks/top/:code' => 'jam_track#dump_top_selling', :via => :get
match '/api/jam_tracks/released' => 'jam_track#dump_released', :via => :get, as: 'released_jamtracks_csv'

View File

@ -339,4 +339,5 @@ acapella_rename.sql
jamblaster_pairing_active.sql
email_blacklist.sql
jamblaster_connection.sql
teacher_progression.sql
teacher_progression.sql
teacher_complete.sql

View File

@ -0,0 +1,2 @@
ALTER TABLE teachers ADD COLUMN profile_pct NUMERIC(8,2) ;
ALTER TABLE teachers ADD COLUMN profile_pct_summary JSON;

View File

@ -35,6 +35,15 @@ module JamRuby
default_scope { includes(:genres).order('created_at desc') }
after_save :update_profile_pct
def update_profile_pct
result = pct_complete
self.profile_pct = result[:pct]
self.profile_pct_summary = result.to_json
Teacher.where(id: id).update_all(profile_pct: self.profile_pct, profile_pct_summary: self.profile_pct_summary)
end
def self.index(user, params = {})
limit = params[:per_page]

View File

@ -36,7 +36,7 @@ module JamRuby
acts_as_mappable
# after_save :check_lat_lng
after_save :update_teacher_pct
attr_accessible :first_name, :last_name, :email, :city, :password, :password_confirmation, :state, :country, :birth_date, :subscribe_email, :terms_of_service, :original_fpfile, :cropped_fpfile, :cropped_large_fpfile, :cropped_s3_path, :cropped_large_s3_path, :photo_url, :large_photo_url, :crop_selection
@ -243,6 +243,11 @@ module JamRuby
scope :musicians_geocoded, musicians.geocoded_users
scope :email_opt_in, where(:subscribe_email => true)
def update_teacher_pct
if teacher
teacher.update_profile_pct
end
end
def user_progression_fields
@user_progression_fields ||= Set.new ["first_downloaded_client_at", "first_ran_client_at", "first_music_session_at", "first_real_music_session_at", "first_good_music_session_at", "first_certified_gear_at", "first_invited_at", "first_friended_at", "first_recording_at", "first_social_promoted_at", "first_played_jamtrack_at"]
end

View File

@ -15,4 +15,10 @@ namespace :users do
end
end
task :update_profile_pct do |task, args|
Teacher.all.each do |teacher|
teacher.update_profile_pct
end
end
end