From d1b13e7c3579d59e5e4ca3c1459a03e4756166ca Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Tue, 20 Nov 2018 19:56:02 -0600 Subject: [PATCH 1/3] Remove bootsnap It was causing weird hangs while booting the app. --- Gemfile | 1 - config/boot.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index 19ad205f..ead1e3eb 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,6 @@ source 'https://rubygems.org' gem 'rails', '~> 5.2.1' gem 'sass-rails', '~> 5.0' gem 'coffee-rails', '~> 4.2.0' -gem 'bootsnap', '~> 1.1' #gem 'json' diff --git a/config/boot.rb b/config/boot.rb index b9e460ce..30f5120d 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. -require 'bootsnap/setup' # Speed up boot time by caching expensive operations. From d3c9975606978769718de05b21b568556a140d6a Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Tue, 20 Nov 2018 19:56:50 -0600 Subject: [PATCH 2/3] allow newer rails to rewrite the schema --- db/schema.rb | 303 ++++++++++++++++++++++++--------------------------- 1 file changed, 144 insertions(+), 159 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index cd711de6..93a6c96f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # 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. @@ -11,230 +10,216 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160131233303) do +ActiveRecord::Schema.define(version: 2016_01_31_233303) do - create_table "attachments", force: true do |t| - t.integer "todo_id" - t.string "file_file_name" - t.string "file_content_type" - t.integer "file_file_size" + create_table "attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "todo_id" + t.string "file_file_name" + t.string "file_content_type" + t.integer "file_file_size" t.datetime "file_updated_at" t.datetime "created_at" t.datetime "updated_at" + t.index ["todo_id"], name: "index_attachments_on_todo_id" end - add_index "attachments", ["todo_id"], name: "index_attachments_on_todo_id", using: :btree - - create_table "contexts", force: true do |t| - t.string "name", null: false - t.integer "position", default: 0 - t.integer "user_id", default: 1 + create_table "contexts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name", null: false + t.integer "position", default: 0 + t.integer "user_id", default: 1 t.datetime "created_at" t.datetime "updated_at" - t.string "state", limit: 20, default: "active", null: false + t.string "state", limit: 20, default: "active", null: false + t.index ["user_id", "name"], name: "index_contexts_on_user_id_and_name" + t.index ["user_id"], name: "index_contexts_on_user_id" end - add_index "contexts", ["user_id", "name"], name: "index_contexts_on_user_id_and_name", using: :btree - add_index "contexts", ["user_id"], name: "index_contexts_on_user_id", using: :btree - - create_table "dependencies", force: true do |t| - t.integer "successor_id", null: false - t.integer "predecessor_id", null: false - t.string "relationship_type" + create_table "dependencies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "successor_id", null: false + t.integer "predecessor_id", null: false + t.string "relationship_type" + t.index ["predecessor_id"], name: "index_dependencies_on_predecessor_id" + t.index ["successor_id"], name: "index_dependencies_on_successor_id" end - add_index "dependencies", ["predecessor_id"], name: "index_dependencies_on_predecessor_id", using: :btree - add_index "dependencies", ["successor_id"], name: "index_dependencies_on_successor_id", using: :btree - - create_table "notes", force: true do |t| - t.integer "user_id", null: false - t.integer "project_id", null: false - t.text "body" + create_table "notes", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "project_id", null: false + t.text "body" t.datetime "created_at" t.datetime "updated_at" + t.index ["project_id"], name: "index_notes_on_project_id" + t.index ["user_id"], name: "index_notes_on_user_id" end - add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree - add_index "notes", ["user_id"], name: "index_notes_on_user_id", using: :btree - - create_table "open_id_authentication_associations", force: true do |t| + create_table "open_id_authentication_associations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "issued" t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" + t.string "handle" + t.string "assoc_type" + t.binary "server_url" + t.binary "secret" end - create_table "open_id_authentication_nonces", force: true do |t| - t.integer "timestamp", null: false - t.string "server_url" - t.string "salt", null: false + create_table "open_id_authentication_nonces", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "timestamp", null: false + t.string "server_url" + t.string "salt", null: false end - create_table "preferences", force: true do |t| - t.integer "user_id", null: false - t.string "date_format", limit: 40, default: "%d/%m/%Y", null: false - t.integer "week_starts", default: 0, null: false - t.integer "show_number_completed", default: 5, null: false - t.integer "staleness_starts", default: 7, null: false - t.boolean "show_completed_projects_in_sidebar", default: true, null: false - t.boolean "show_hidden_contexts_in_sidebar", default: true, null: false - t.integer "due_style", default: 0, null: false - t.integer "refresh", default: 0, null: false - t.boolean "verbose_action_descriptors", default: false, null: false - t.boolean "show_hidden_projects_in_sidebar", default: true, null: false - t.string "time_zone", default: "London", null: false - t.boolean "show_project_on_todo_done", default: false, null: false - t.string "title_date_format", default: "%A, %d %B %Y", null: false - t.integer "mobile_todos_per_page", default: 6, null: false - t.string "sms_email" + create_table "preferences", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "user_id", null: false + t.string "date_format", limit: 40, default: "%d/%m/%Y", null: false + t.integer "week_starts", default: 0, null: false + t.integer "show_number_completed", default: 5, null: false + t.integer "staleness_starts", default: 7, null: false + t.boolean "show_completed_projects_in_sidebar", default: true, null: false + t.boolean "show_hidden_contexts_in_sidebar", default: true, null: false + t.integer "due_style", default: 0, null: false + t.integer "refresh", default: 0, null: false + t.boolean "verbose_action_descriptors", default: false, null: false + t.boolean "show_hidden_projects_in_sidebar", default: true, null: false + t.string "time_zone", default: "London", null: false + t.boolean "show_project_on_todo_done", default: false, null: false + t.string "title_date_format", default: "%A, %d %B %Y", null: false + t.integer "mobile_todos_per_page", default: 6, null: false + t.string "sms_email" t.integer "sms_context_id" - t.string "locale" - t.integer "review_period", default: 14, null: false + t.string "locale" + t.integer "review_period", default: 14, null: false + t.index ["user_id"], name: "index_preferences_on_user_id" end - add_index "preferences", ["user_id"], name: "index_preferences_on_user_id", using: :btree - - create_table "projects", force: true do |t| - t.string "name", null: false - t.integer "position", default: 0 - t.integer "user_id", default: 1 - t.text "description", limit: 16777215 - t.string "state", limit: 20, null: false + create_table "projects", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name", null: false + t.integer "position", default: 0 + t.integer "user_id", default: 1 + t.text "description", limit: 16777215 + t.string "state", limit: 20, null: false t.datetime "created_at" t.datetime "updated_at" - t.integer "default_context_id" + t.integer "default_context_id" t.datetime "completed_at" - t.string "default_tags" + t.string "default_tags" t.datetime "last_reviewed" + t.index ["state"], name: "index_projects_on_state" + t.index ["user_id", "name"], name: "index_projects_on_user_id_and_name" + t.index ["user_id", "state"], name: "index_projects_on_user_id_and_state" + t.index ["user_id"], name: "index_projects_on_user_id" end - add_index "projects", ["state"], name: "index_projects_on_state", using: :btree - add_index "projects", ["user_id", "name"], name: "index_projects_on_user_id_and_name", using: :btree - add_index "projects", ["user_id", "state"], name: "index_projects_on_user_id_and_state", using: :btree - add_index "projects", ["user_id"], name: "index_projects_on_user_id", using: :btree - - create_table "recurring_todos", force: true do |t| - t.integer "user_id", default: 1 - t.integer "context_id", null: false - t.integer "project_id" - t.string "description", null: false - t.text "notes", limit: 16777215 - t.string "state", limit: 20, null: false + create_table "recurring_todos", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "user_id", default: 1 + t.integer "context_id", null: false + t.integer "project_id" + t.string "description", null: false + t.text "notes", limit: 16777215 + t.string "state", limit: 20, null: false t.datetime "start_from" - t.string "ends_on" + t.string "ends_on" t.datetime "end_date" - t.integer "number_of_occurrences" - t.integer "occurrences_count", default: 0 - t.string "target" - t.integer "show_from_delta" - t.string "recurring_period" - t.integer "recurrence_selector" - t.integer "every_other1" - t.integer "every_other2" - t.integer "every_other3" - t.string "every_day" - t.boolean "only_work_days", default: false - t.integer "every_count" - t.integer "weekday" + t.integer "number_of_occurrences" + t.integer "occurrences_count", default: 0 + t.string "target" + t.integer "show_from_delta" + t.string "recurring_period" + t.integer "recurrence_selector" + t.integer "every_other1" + t.integer "every_other2" + t.integer "every_other3" + t.string "every_day" + t.boolean "only_work_days", default: false + t.integer "every_count" + t.integer "weekday" t.datetime "completed_at" t.datetime "created_at" t.datetime "updated_at" - t.boolean "show_always" + t.boolean "show_always" + t.index ["state"], name: "index_recurring_todos_on_state" + t.index ["user_id"], name: "index_recurring_todos_on_user_id" end - add_index "recurring_todos", ["state"], name: "index_recurring_todos_on_state", using: :btree - add_index "recurring_todos", ["user_id"], name: "index_recurring_todos_on_user_id", using: :btree - - create_table "sessions", force: true do |t| - t.string "session_id" - t.text "data" + create_table "sessions", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "session_id" + t.text "data" t.datetime "updated_at" + t.index ["session_id"], name: "sessions_session_id_index" end - add_index "sessions", ["session_id"], name: "sessions_session_id_index", using: :btree - - create_table "taggings", force: true do |t| + create_table "taggings", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "taggable_id" t.integer "tag_id" - t.string "taggable_type" + t.string "taggable_type" + t.index ["tag_id", "taggable_id", "taggable_type"], name: "index_taggings_on_tag_id_and_taggable_id_and_taggable_type" + t.index ["tag_id"], name: "index_taggings_on_tag_id" + t.index ["taggable_id", "taggable_type"], name: "index_taggings_on_taggable_id_and_taggable_type" end - add_index "taggings", ["tag_id", "taggable_id", "taggable_type"], name: "index_taggings_on_tag_id_and_taggable_id_and_taggable_type", using: :btree - add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree - add_index "taggings", ["taggable_id", "taggable_type"], name: "index_taggings_on_taggable_id_and_taggable_type", using: :btree - - create_table "tags", force: true do |t| - t.string "name" + create_table "tags", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name" t.datetime "created_at" t.datetime "updated_at" + t.index ["name"], name: "index_tags_on_name" end - add_index "tags", ["name"], name: "index_tags_on_name", using: :btree - - create_table "todos", force: true do |t| - t.integer "context_id", null: false - t.integer "project_id" - t.string "description", null: false - t.text "notes", limit: 16777215 + create_table "todos", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "context_id", null: false + t.integer "project_id" + t.string "description", null: false + t.text "notes", limit: 16777215 t.datetime "created_at" t.datetime "due" t.datetime "completed_at" - t.integer "user_id", default: 1 + t.integer "user_id", default: 1 t.datetime "show_from" - t.string "state", limit: 20, null: false - t.integer "recurring_todo_id" + t.string "state", limit: 20, null: false + t.integer "recurring_todo_id" t.datetime "updated_at" - t.text "rendered_notes", limit: 16777215 + t.text "rendered_notes", limit: 16777215 + t.index ["context_id"], name: "index_todos_on_context_id" + t.index ["project_id"], name: "index_todos_on_project_id" + t.index ["state"], name: "index_todos_on_state" + t.index ["user_id", "context_id"], name: "index_todos_on_user_id_and_context_id" + t.index ["user_id", "project_id"], name: "index_todos_on_user_id_and_project_id" + t.index ["user_id", "state"], name: "index_todos_on_user_id_and_state" end - add_index "todos", ["context_id"], name: "index_todos_on_context_id", using: :btree - add_index "todos", ["project_id"], name: "index_todos_on_project_id", using: :btree - add_index "todos", ["state"], name: "index_todos_on_state", using: :btree - add_index "todos", ["user_id", "context_id"], name: "index_todos_on_user_id_and_context_id", using: :btree - add_index "todos", ["user_id", "project_id"], name: "index_todos_on_user_id_and_project_id", using: :btree - add_index "todos", ["user_id", "state"], name: "index_todos_on_user_id_and_state", using: :btree + create_table "tolk_locales", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["name"], name: "index_tolk_locales_on_name", unique: true + end - create_table "tolk_locales", force: true do |t| - t.string "name" + create_table "tolk_phrases", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.text "key" t.datetime "created_at" t.datetime "updated_at" end - add_index "tolk_locales", ["name"], name: "index_tolk_locales_on_name", unique: true, using: :btree - - create_table "tolk_phrases", force: true do |t| - t.text "key" + create_table "tolk_translations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.integer "phrase_id" + t.integer "locale_id" + t.text "text" + t.text "previous_text" + t.boolean "primary_updated", default: false t.datetime "created_at" t.datetime "updated_at" + t.index ["phrase_id", "locale_id"], name: "index_tolk_translations_on_phrase_id_and_locale_id", unique: true end - create_table "tolk_translations", force: true do |t| - t.integer "phrase_id" - t.integer "locale_id" - t.text "text" - t.text "previous_text" - t.boolean "primary_updated", default: false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "tolk_translations", ["phrase_id", "locale_id"], name: "index_tolk_translations_on_phrase_id_and_locale_id", unique: true, using: :btree - - create_table "users", force: true do |t| - t.string "login", limit: 80, null: false - t.string "crypted_password", limit: 60 - t.string "token" - t.boolean "is_admin", default: false, null: false - t.string "first_name" - t.string "last_name" - t.string "auth_type", default: "database", null: false - t.string "open_id_url" - t.string "remember_token" + create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + t.string "login", limit: 80, null: false + t.string "crypted_password", limit: 60 + t.string "token" + t.boolean "is_admin", default: false, null: false + t.string "first_name" + t.string "last_name" + t.string "auth_type", default: "database", null: false + t.string "open_id_url" + t.string "remember_token" t.datetime "remember_token_expires_at" + t.index ["login"], name: "index_users_on_login" end - add_index "users", ["login"], name: "index_users_on_login", using: :btree - end From f2647e3f9418e07cead475b1337efc00de9b77fa Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Tue, 20 Nov 2018 19:57:02 -0600 Subject: [PATCH 3/3] Remove deprecations printed out in the test suite --- app/controllers/contexts_controller.rb | 4 ++-- app/controllers/todos_controller.rb | 10 +++++----- app/models/context.rb | 2 +- app/models/project.rb | 2 +- app/models/search/search_results.rb | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index b6e4f6b9..45959d51 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -39,8 +39,8 @@ class ContextsController < ApplicationController unless @context.nil? @max_completed = current_user.prefs.show_number_completed - @done = @context.todos.completed.limit(@max_completed).reorder("todos.completed_at DESC, todos.created_at DESC").includes(Todo::DEFAULT_INCLUDES) - @not_done_todos = @context.todos.active_or_hidden.not_project_hidden.reorder('todos.due IS NULL, todos.due ASC, todos.created_at ASC').includes(Todo::DEFAULT_INCLUDES) + @done = @context.todos.completed.limit(@max_completed).reorder(Arel.sql("todos.completed_at DESC, todos.created_at DESC")).includes(Todo::DEFAULT_INCLUDES) + @not_done_todos = @context.todos.active_or_hidden.not_project_hidden.reorder(Arel.sql('todos.due IS NULL, todos.due ASC, todos.created_at ASC')).includes(Todo::DEFAULT_INCLUDES) @todos_without_project = @not_done_todos.select{|t| t.project.nil?} @deferred_todos = @context.todos.deferred.includes(Todo::DEFAULT_INCLUDES) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 21f4da8c..eb7be53d 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -629,19 +629,19 @@ class TodosController < ApplicationController @not_done_todos = todos_with_tag_ids. active.not_hidden. - reorder('todos.due IS NULL, todos.due ASC, todos.created_at ASC'). + reorder(Arel.sql('todos.due IS NULL, todos.due ASC, todos.created_at ASC')). includes(Todo::DEFAULT_INCLUDES) @hidden_todos = todos_with_tag_ids. hidden. - reorder('todos.completed_at DESC, todos.created_at DESC'). + reorder(Arel.sql('todos.completed_at DESC, todos.created_at DESC')). includes(Todo::DEFAULT_INCLUDES) @deferred_todos = todos_with_tag_ids. deferred. - reorder('todos.show_from ASC, todos.created_at DESC'). + reorder(Arel.sql('todos.show_from ASC, todos.created_at DESC')). includes(Todo::DEFAULT_INCLUDES) @pending_todos = todos_with_tag_ids. blocked. - reorder('todos.show_from ASC, todos.created_at DESC'). + reorder(Arel.sql('todos.show_from ASC, todos.created_at DESC')). includes(Todo::DEFAULT_INCLUDES) @todos_without_project = @not_done_todos.select{|t| t.project.nil?} @@ -1323,7 +1323,7 @@ end end not_done_todos = not_done_todos. - reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC"). + reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")). includes(Todo::DEFAULT_INCLUDES) not_done_todos = not_done_todos.limit(sanitize(params[:limit])) if params[:limit] diff --git a/app/models/context.rb b/app/models/context.rb index d8c9fb8d..f9331fcb 100644 --- a/app/models/context.rb +++ b/app/models/context.rb @@ -1,6 +1,6 @@ class Context < ApplicationRecord - has_many :todos, -> { order("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(:project) }, :dependent => :delete_all + has_many :todos, -> { order(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")).includes(:project) }, :dependent => :delete_all has_many :recurring_todos, :dependent => :delete_all belongs_to :user diff --git a/app/models/project.rb b/app/models/project.rb index 0b053536..091827f4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,5 +1,5 @@ class Project < ApplicationRecord - has_many :todos, -> {order("todos.due IS NULL, todos.due ASC, todos.created_at ASC")}, dependent: :delete_all + has_many :todos, -> {order(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))}, dependent: :delete_all has_many :notes, -> {order "created_at DESC"}, dependent: :delete_all has_many :recurring_todos diff --git a/app/models/search/search_results.rb b/app/models/search/search_results.rb index 692d0fd0..36130db3 100644 --- a/app/models/search/search_results.rb +++ b/app/models/search/search_results.rb @@ -29,7 +29,7 @@ module Search @user.todos. where("(todos.description LIKE ? OR todos.notes LIKE ?) AND todos.completed_at IS NULL", terms, terms). includes(Todo::DEFAULT_INCLUDES). - reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC") + reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC")) end def complete_todos(terms)