Skip to content

Commit

Permalink
Merge pull request #1 from thekeenant/remove-trends
Browse files Browse the repository at this point in the history
Remove trends/changes tables
  • Loading branch information
thekeenant authored Apr 4, 2018
2 parents 5e81b68 + 28d3361 commit 809f062
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 347 deletions.
26 changes: 0 additions & 26 deletions app/controllers/v1/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,6 @@ def index

# if the user uses these sorting methods, we have a special query
if %w(trending_recent trending_all trending_gpa_recent trending_gpa_all).include?(sort)
@courses = Course.joins('JOIN course_changes ON course_changes.course_uuid = courses.uuid')

if sort == 'trending_recent'
@courses = @courses
.where("course_changes.duration = 'recent'")
.order("count_change #{order}")
elsif sort == 'trending_all'
@courses = @courses
.where("course_changes.duration = 'all'")
.order("count_change #{order}")
elsif sort == 'trending_gpa_recent'
@courses = @courses
.where("course_changes.duration = 'recent'")
.order("gpa_change #{order}")
elsif sort == 'trending_gpa_all'
@courses = @courses
.where("course_changes.duration = 'all'")
.order("gpa_change #{order}")
end

# # prevents tiny 1-5 people courses and courses taught too long ago from trending
# earliest_allowed = -15 + CourseOffering
# .select('MAX(term_code) as term_code')
# .first
# .term_code
# @courses = @courses.where("last_count > 50 AND last_term > #{earliest_allowed} AND last_term - first_term > 2")
elsif sort == 'name'
@courses = Course.order("name #{order}")
elsif sort == 'number'
Expand Down
76 changes: 0 additions & 76 deletions app/controllers/v1/grades_controller.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ def self.search_without_page(query)
Course.search(query, misspellings: {below: 5})
end

def change(duration)
CourseChange.where(course_uuid: uuid, duration: duration).first
end

def search_data
{
names: "#{subject_names.join(' ')} #{subject_initials.join(' ')} #{subject_abbrevs.join(' ')} #{names.join(' ')} #{number}",
Expand Down
23 changes: 0 additions & 23 deletions app/models/course_change.rb

This file was deleted.

31 changes: 0 additions & 31 deletions app/models/course_offering_grade_dist.rb

This file was deleted.

33 changes: 0 additions & 33 deletions app/models/instructor_grade_dist.rb

This file was deleted.

45 changes: 6 additions & 39 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,21 @@
# MySQL. Versions 5.1.10 and up are supported.
#
# Install the MySQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.7/en/old-client.html
#
default: &default
adapter: mysql2
encoding: utf8
pool: 10
username: root
password: password
socket: /var/run/mysqld/mysqld.sock
username: remote
password: 067dcea2cf57
host: server.madgrades.com
port: 3306
# socket: /var/run/mysqld/mysqld.sock

development:
<<: *default
database: madgrades_dev
database: madgrades

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: madgrades_test

# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: madgrades
username: root
password: password
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
config.active_record.migration_error = false # :page_load

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
Expand Down
10 changes: 1 addition & 9 deletions config/initializers/scheduler.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
scheduler = Rufus::Scheduler::singleton

def populate_course_grades
course_offering_count = GradeDistribution.select(:course_uuid).group(:course_uuid).count

if course_offering_count != CourseOfferingGradeDist.count
CourseOfferingGradeDist.populate!
end
end

unless defined?(Rails::Console) || File.split($0).last == 'rake'
scheduler.every '7d' do
populate_course_grades
# ...
end
end
5 changes: 5 additions & 0 deletions db/migrate/20180404203823_drop_table_course_change.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DropTableCourseChange < ActiveRecord::Migration[5.1]
def change
drop_table :course_changes
end
end
9 changes: 1 addition & 8 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180310191259) do

create_table "course_changes", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "course_uuid"
t.decimal "count_change", precision: 10, scale: 6
t.decimal "gpa_change", precision: 10, scale: 6
t.string "duration"
end
ActiveRecord::Schema.define(version: 20180404203823) do

create_table "course_offering_grade_dists", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "course_uuid"
Expand Down
76 changes: 0 additions & 76 deletions lib/course_changes.sql

This file was deleted.

Loading

0 comments on commit 809f062

Please sign in to comment.