Skip to content

Commit

Permalink
Rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Naviunni committed Oct 30, 2024
1 parent ecd366c commit acca9f3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 96 deletions.
2 changes: 1 addition & 1 deletion app/controllers/room_bookings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def index

# Fetch room bookings only for the specified schedule
@room_bookings = RoomBooking.joins(:room, :time_slot)
.where(rooms: { schedule_id: schedule_id }, time_slots: { day: @active_tab })
.where(rooms: { schedule_id: }, time_slots: { day: @active_tab })

# Organize room bookings in a hash with room_id and time_slot_id as keys
@bookings_matrix = @room_bookings.each_with_object({}) do |booking, hash|
Expand Down
184 changes: 93 additions & 91 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand All @@ -10,113 +12,113 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_10_29_040851) do
create_table "courses", force: :cascade do |t|
t.string "course_number"
t.integer "max_seats"
t.string "lecture_type"
t.integer "num_labs"
t.integer "schedule_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["schedule_id"], name: "index_courses_on_schedule_id"
ActiveRecord::Schema[7.2].define(version: 20_241_029_040_851) do
create_table 'courses', force: :cascade do |t|
t.string 'course_number'
t.integer 'max_seats'
t.string 'lecture_type'
t.integer 'num_labs'
t.integer 'schedule_id', null: false
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.index ['schedule_id'], name: 'index_courses_on_schedule_id'
end

create_table "instructor_preferences", force: :cascade do |t|
t.integer "instructor_id", null: false
t.integer "preference_level"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "course_id", null: false
t.index ["course_id"], name: "index_instructor_preferences_on_course_id"
t.index ["instructor_id"], name: "index_instructor_preferences_on_instructor_id"
create_table 'instructor_preferences', force: :cascade do |t|
t.integer 'instructor_id', null: false
t.integer 'preference_level'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.integer 'course_id', null: false
t.index ['course_id'], name: 'index_instructor_preferences_on_course_id'
t.index ['instructor_id'], name: 'index_instructor_preferences_on_instructor_id'
end

create_table "instructors", force: :cascade do |t|
t.integer "id_number"
t.string "last_name"
t.string "first_name"
t.string "middle_name"
t.string "email"
t.boolean "before_9"
t.boolean "after_3"
t.text "beaware_of"
t.integer "schedule_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "max_course_load"
t.index ["schedule_id"], name: "index_instructors_on_schedule_id"
create_table 'instructors', force: :cascade do |t|
t.integer 'id_number'
t.string 'last_name'
t.string 'first_name'
t.string 'middle_name'
t.string 'email'
t.boolean 'before_9'
t.boolean 'after_3'
t.text 'beaware_of'
t.integer 'schedule_id'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.integer 'max_course_load'
t.index ['schedule_id'], name: 'index_instructors_on_schedule_id'
end

create_table "room_bookings", force: :cascade do |t|
t.integer "room_id", null: false
t.integer "time_slot_id", null: false
t.boolean "is_available"
t.boolean "is_lab"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["room_id"], name: "index_room_bookings_on_room_id"
t.index ["time_slot_id"], name: "index_room_bookings_on_time_slot_id"
create_table 'room_bookings', force: :cascade do |t|
t.integer 'room_id', null: false
t.integer 'time_slot_id', null: false
t.boolean 'is_available'
t.boolean 'is_lab'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.index ['room_id'], name: 'index_room_bookings_on_room_id'
t.index ['time_slot_id'], name: 'index_room_bookings_on_time_slot_id'
end

create_table "rooms", force: :cascade do |t|
t.integer "campus"
t.boolean "is_lecture_hall"
t.boolean "is_learning_studio"
t.boolean "is_lab"
t.string "building_code"
t.string "room_number"
t.integer "capacity"
t.boolean "is_active"
t.string "comments"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "schedule_id", default: -1, null: false
t.index ["schedule_id"], name: "index_rooms_on_schedule_id"
create_table 'rooms', force: :cascade do |t|
t.integer 'campus'
t.boolean 'is_lecture_hall'
t.boolean 'is_learning_studio'
t.boolean 'is_lab'
t.string 'building_code'
t.string 'room_number'
t.integer 'capacity'
t.boolean 'is_active'
t.string 'comments'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.integer 'schedule_id', default: -1, null: false
t.index ['schedule_id'], name: 'index_rooms_on_schedule_id'
end

create_table "schedules", force: :cascade do |t|
t.string "schedule_name"
t.string "semester_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table 'schedules', force: :cascade do |t|
t.string 'schedule_name'
t.string 'semester_name'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
end

create_table "sections", force: :cascade do |t|
t.string "section_number"
t.integer "seats_alloted"
t.integer "course_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["course_id"], name: "index_sections_on_course_id"
create_table 'sections', force: :cascade do |t|
t.string 'section_number'
t.integer 'seats_alloted'
t.integer 'course_id', null: false
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.index ['course_id'], name: 'index_sections_on_course_id'
end

create_table "time_slots", force: :cascade do |t|
t.string "day"
t.string "start_time"
t.string "end_time"
t.string "slot_type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table 'time_slots', force: :cascade do |t|
t.string 'day'
t.string 'start_time'
t.string 'end_time'
t.string 'slot_type'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
end

create_table "users", force: :cascade do |t|
t.string "email"
t.string "first_name"
t.string "last_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "uid"
t.string "provider"
t.index ["email"], name: "index_users_on_email", unique: true
create_table 'users', force: :cascade do |t|
t.string 'email'
t.string 'first_name'
t.string 'last_name'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.string 'uid'
t.string 'provider'
t.index ['email'], name: 'index_users_on_email', unique: true
end

add_foreign_key "courses", "schedules"
add_foreign_key "instructor_preferences", "courses"
add_foreign_key "instructor_preferences", "instructors"
add_foreign_key "instructors", "schedules"
add_foreign_key "room_bookings", "rooms"
add_foreign_key "room_bookings", "time_slots"
add_foreign_key "rooms", "schedules"
add_foreign_key "sections", "courses"
add_foreign_key 'courses', 'schedules'
add_foreign_key 'instructor_preferences', 'courses'
add_foreign_key 'instructor_preferences', 'instructors'
add_foreign_key 'instructors', 'schedules'
add_foreign_key 'room_bookings', 'rooms'
add_foreign_key 'room_bookings', 'time_slots'
add_foreign_key 'rooms', 'schedules'
add_foreign_key 'sections', 'courses'
end
4 changes: 2 additions & 2 deletions features/step_definitions/room_bookings_steps.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

Given(/I am on the room bookings page for "(.*)"/) do |schedule_name|
@schedule = Schedule.find(schedule_name: schedule_name)
@schedule = Schedule.find(schedule_name:)
visit schedule_room_bookings_path(@schedule)
end

When(/^I visit the room bookings page for "(.*)"$/) do |schedule_name|
@schedule = Schedule.where(schedule_name: schedule_name)[0]
@schedule = Schedule.where(schedule_name:)[0]
visit schedule_room_bookings_path(schedule_id: @schedule.id)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/room_bookings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

RSpec.describe RoomBookingsController, type: :controller do
let!(:schedule) { create(:schedule) }
let!(:room1) { create(:room, schedule: schedule) }
let!(:room2) { create(:room, schedule: schedule) }
let!(:room1) { create(:room, schedule:) }
let!(:room2) { create(:room, schedule:) }
let!(:time_slot1) { create(:time_slot, day: 'Monday', start_time: '09:00', end_time: '10:00') }
let!(:time_slot2) { create(:time_slot, day: 'Monday', start_time: '10:00', end_time: '11:00') }
let!(:room_booking1) { create(:room_booking, room: room1, time_slot: time_slot1, is_available: true) }
Expand Down

0 comments on commit acca9f3

Please sign in to comment.