mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Fixes for PostreSQL support
This commit is contained in:
parent
f2c0367a74
commit
1c38b091cc
5 changed files with 39 additions and 33 deletions
2
Gemfile
2
Gemfile
|
|
@ -18,7 +18,9 @@ gem 'rails_12factor', group: :production
|
|||
gem 'responders', '~> 2.0'
|
||||
|
||||
# as the database for Active Record
|
||||
# choose only one
|
||||
gem 'mysql2'
|
||||
#gem 'pg'
|
||||
|
||||
# for observing records
|
||||
gem 'rails-observers'
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class Conference < ActiveRecord::Base
|
|||
result = []
|
||||
|
||||
if program && program.cfp && program.events
|
||||
submissions = program.events.group(:week).count
|
||||
submissions = program.events.select(:week).group(:week).order(:week).count
|
||||
start_week = program.cfp.start_week
|
||||
weeks = program.cfp.weeks
|
||||
result = calculate_items_per_week(start_week, weeks, submissions)
|
||||
|
|
@ -179,7 +179,7 @@ class Conference < ActiveRecord::Base
|
|||
registration_period.start_date &&
|
||||
registration_period.end_date
|
||||
|
||||
reg = registrations.group(:week).count
|
||||
reg = registrations.group(:week).order(:week).count
|
||||
start_week = get_registration_start_week
|
||||
weeks = registration_weeks
|
||||
result = calculate_items_per_week(start_week, weeks, reg)
|
||||
|
|
@ -337,8 +337,8 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +hash+ -> user: submissions
|
||||
def self.get_top_submitter(limit = 5)
|
||||
submitter = EventUser.where('event_role = ?', 'submitter').limit(limit).group(:user_id)
|
||||
counter = submitter.order('count_all desc').count
|
||||
submitter = EventUser.select(:user_id).where('event_role = ?', 'submitter').limit(limit).group(:user_id)
|
||||
counter = submitter.order('count_all desc').count(:all)
|
||||
calculate_user_submission_hash(submitter, counter)
|
||||
end
|
||||
|
||||
|
|
@ -348,10 +348,10 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +hash+ -> user: submissions
|
||||
def get_top_submitter(limit = 5)
|
||||
submitter = EventUser.joins(:event)
|
||||
submitter = EventUser.joins(:event).select(:user_id)
|
||||
.where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id)
|
||||
.limit(limit).group(:user_id)
|
||||
counter = submitter.order('count_all desc').count
|
||||
counter = submitter.order('count_all desc').count(:all)
|
||||
Conference.calculate_user_submission_hash(submitter, counter)
|
||||
end
|
||||
|
||||
|
|
@ -1100,7 +1100,8 @@ class Conference < ActiveRecord::Base
|
|||
def self.calculate_user_submission_hash(submitters, counter)
|
||||
result = ActiveSupport::OrderedHash.new
|
||||
counter.each do |key, value|
|
||||
submitter = submitters.where(user_id: key).first
|
||||
# make PG happy by including the user_id in ORDER
|
||||
submitter = submitters.where(user_id: key).order(:user_id).first
|
||||
if submitter
|
||||
result[submitter.user] = value
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
.page-header
|
||||
%h1
|
||||
Missing Speakers
|
||||
= "(#{@missing_event_speakers.group(:user_id).length})"
|
||||
= "(#{@missing_event_speakers.distinct(:user_id).length})"
|
||||
%p.text-muted
|
||||
All event speakers who haven't checked in
|
||||
.col-md-12
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
%a{href: '#missing-speakers', 'data-toggle' => 'tab'}
|
||||
Missing Speakers
|
||||
%span.label.label-danger{style: 'border-radius: 1em;'}
|
||||
= @missing_event_speakers.group(:user_id).length
|
||||
= @missing_event_speakers.distinct(:user_id).length
|
||||
|
||||
.tab-content
|
||||
#all.tab-pane.active
|
||||
|
|
|
|||
51
db/schema.rb
51
db/schema.rb
|
|
@ -13,17 +13,20 @@
|
|||
|
||||
ActiveRecord::Schema.define(version: 20170531094819) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "ahoy_events", force: :cascade do |t|
|
||||
t.uuid "visit_id", limit: 16
|
||||
t.integer "visit_id"
|
||||
t.integer "user_id"
|
||||
t.string "name"
|
||||
t.text "properties"
|
||||
t.datetime "time"
|
||||
end
|
||||
|
||||
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time"
|
||||
add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id"
|
||||
add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id"
|
||||
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree
|
||||
add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id", using: :btree
|
||||
add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id", using: :btree
|
||||
|
||||
create_table "answers", force: :cascade do |t|
|
||||
t.string "title"
|
||||
|
|
@ -65,9 +68,9 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.integer "rgt"
|
||||
end
|
||||
|
||||
add_index "comments", ["commentable_id"], name: "index_comments_on_commentable_id"
|
||||
add_index "comments", ["commentable_type"], name: "index_comments_on_commentable_type"
|
||||
add_index "comments", ["user_id"], name: "index_comments_on_user_id"
|
||||
add_index "comments", ["commentable_id"], name: "index_comments_on_commentable_id", using: :btree
|
||||
add_index "comments", ["commentable_type"], name: "index_comments_on_commentable_type", using: :btree
|
||||
add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree
|
||||
|
||||
create_table "commercials", force: :cascade do |t|
|
||||
t.string "commercial_id"
|
||||
|
|
@ -137,7 +140,7 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority"
|
||||
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
|
||||
|
||||
create_table "difficulty_levels", force: :cascade do |t|
|
||||
t.string "title"
|
||||
|
|
@ -190,10 +193,10 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "event_schedules", ["event_id", "schedule_id"], name: "index_event_schedules_on_event_id_and_schedule_id", unique: true
|
||||
add_index "event_schedules", ["event_id"], name: "index_event_schedules_on_event_id"
|
||||
add_index "event_schedules", ["room_id"], name: "index_event_schedules_on_room_id"
|
||||
add_index "event_schedules", ["schedule_id"], name: "index_event_schedules_on_schedule_id"
|
||||
add_index "event_schedules", ["event_id", "schedule_id"], name: "index_event_schedules_on_event_id_and_schedule_id", unique: true, using: :btree
|
||||
add_index "event_schedules", ["event_id"], name: "index_event_schedules_on_event_id", using: :btree
|
||||
add_index "event_schedules", ["room_id"], name: "index_event_schedules_on_room_id", using: :btree
|
||||
add_index "event_schedules", ["schedule_id"], name: "index_event_schedules_on_schedule_id", using: :btree
|
||||
|
||||
create_table "event_types", force: :cascade do |t|
|
||||
t.string "title", null: false
|
||||
|
|
@ -301,7 +304,7 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.integer "schedule_interval", default: 15, null: false
|
||||
end
|
||||
|
||||
add_index "programs", ["selected_schedule_id"], name: "index_programs_on_selected_schedule_id"
|
||||
add_index "programs", ["selected_schedule_id"], name: "index_programs_on_selected_schedule_id", using: :btree
|
||||
|
||||
create_table "qanswers", force: :cascade do |t|
|
||||
t.integer "question_id"
|
||||
|
|
@ -373,8 +376,8 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.string "resource_type"
|
||||
end
|
||||
|
||||
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
||||
add_index "roles", ["name"], name: "index_roles_on_name"
|
||||
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree
|
||||
add_index "roles", ["name"], name: "index_roles_on_name", using: :btree
|
||||
|
||||
create_table "rooms", force: :cascade do |t|
|
||||
t.string "guid", null: false
|
||||
|
|
@ -389,7 +392,7 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "schedules", ["program_id"], name: "index_schedules_on_program_id"
|
||||
add_index "schedules", ["program_id"], name: "index_schedules_on_program_id", using: :btree
|
||||
|
||||
create_table "splashpages", force: :cascade do |t|
|
||||
t.integer "conference_id"
|
||||
|
|
@ -512,17 +515,17 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.boolean "is_disabled", default: false
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
add_index "users", ["email"], name: "index_users_on_email", unique: true
|
||||
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
add_index "users", ["username"], name: "index_users_on_username", unique: true
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
||||
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
||||
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
||||
add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree
|
||||
|
||||
create_table "users_roles", force: :cascade do |t|
|
||||
t.integer "role_id"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
|
||||
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree
|
||||
|
||||
create_table "vchoices", force: :cascade do |t|
|
||||
t.integer "vday_id"
|
||||
|
|
@ -566,10 +569,10 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.integer "conference_id"
|
||||
end
|
||||
|
||||
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
|
||||
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
|
||||
|
||||
create_table "visits", force: :cascade do |t|
|
||||
t.uuid "visitor_id", limit: 16
|
||||
t.uuid "visitor_id"
|
||||
t.string "ip"
|
||||
t.text "user_agent"
|
||||
t.text "referrer"
|
||||
|
|
@ -591,7 +594,7 @@ ActiveRecord::Schema.define(version: 20170531094819) do
|
|||
t.datetime "started_at"
|
||||
end
|
||||
|
||||
add_index "visits", ["user_id"], name: "index_visits_on_user_id"
|
||||
add_index "visits", ["user_id"], name: "index_visits_on_user_id", using: :btree
|
||||
|
||||
create_table "votes", force: :cascade do |t|
|
||||
t.integer "event_id"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue