From f86628a71eeae794c6b7b7843a48dc8553e154da Mon Sep 17 00:00:00 2001 From: IkumaTadokoro Date: Wed, 10 Nov 2021 15:32:57 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Products.self=5Flast=5Fcomment=5Fat?= =?UTF-8?q?=E3=82=92self=5Flast=5Fcommented=5Fat=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/product.vue | 14 +++++++------- app/models/comment_callbacks.rb | 6 +++--- app/views/api/products/_product.json.jbuilder | 6 +++--- ...1152_rename_self_last_comment_at_to_products.rb | 5 +++++ db/schema.rb | 4 ++-- 5 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20211110061152_rename_self_last_comment_at_to_products.rb diff --git a/app/javascript/product.vue b/app/javascript/product.vue index 14fc63ba06a..d93666afa75 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -70,25 +70,25 @@ ) .thread-list-item-meta__item( - v-if='product.self_last_comment_at_date_time && product.mentor_last_comment_at_date_time' + v-if='product.self_last_commented_at_date_time && product.mentor_last_comment_at_date_time' ) time.a-meta( - v-if='product.self_last_comment_at_date_time > product.mentor_last_comment_at_date_time' + v-if='product.self_last_commented_at_date_time > product.mentor_last_comment_at_date_time' ) - | 〜 {{ product.self_last_comment_at }}( + | 〜 {{ product.self_last_commented_at }}( strong | 提出者 | ) time.a-meta( - v-if='product.self_last_comment_at_date_time < product.mentor_last_comment_at_date_time' + v-if='product.self_last_commented_at_date_time < product.mentor_last_comment_at_date_time' ) | 〜 {{ product.mentor_last_comment_at }}(メンター) .thread-list-item-meta__item( - v-else-if='product.self_last_comment_at_date_time || product.mentor_last_comment_at_date_time' + v-else-if='product.self_last_commented_at_date_time || product.mentor_last_comment_at_date_time' ) - time.a-meta(v-if='product.self_last_comment_at_date_time') - | 〜 {{ product.self_last_comment_at }}( + time.a-meta(v-if='product.self_last_commented_at_date_time') + | 〜 {{ product.self_last_commented_at }}( strong | 提出者 | ) diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index ce3e93aea22..11bc84967ab 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -35,7 +35,7 @@ def after_destroy(comment) def reset_last_comment_at(product) product.mentor_last_comment_at = nil - product.self_last_comment_at = nil + product.self_last_commented_at = nil end def delete_last_comment_at(product_id) @@ -47,7 +47,7 @@ def delete_last_comment_at(product_id) if comment.user.mentor product.mentor_last_comment_at = comment.updated_at elsif comment.user == product.user - product.self_last_comment_at = comment.updated_at + product.self_last_commented_at = comment.updated_at end end product.save! @@ -58,7 +58,7 @@ def update_last_comment_at(comment) if comment.user.mentor product.mentor_last_comment_at = comment.updated_at elsif comment.user == product.user - product.self_last_comment_at = comment.updated_at + product.self_last_commented_at = comment.updated_at end product.save! end diff --git a/app/views/api/products/_product.json.jbuilder b/app/views/api/products/_product.json.jbuilder index 8d8e551593f..4db567990dd 100644 --- a/app/views/api/products/_product.json.jbuilder +++ b/app/views/api/products/_product.json.jbuilder @@ -17,9 +17,9 @@ if product.updated_at.present? json.updated_at_date_time product.updated_at.to_datetime end -if product.self_last_comment_at.present? - json.self_last_comment_at l(product.self_last_comment_at) - json.self_last_comment_at_date_time product.self_last_comment_at.to_datetime +if product.self_last_commented_at.present? + json.self_last_commented_at l(product.self_last_commented_at) + json.self_last_commented_at_date_time product.self_last_commented_at.to_datetime end if product.mentor_last_comment_at.present? diff --git a/db/migrate/20211110061152_rename_self_last_comment_at_to_products.rb b/db/migrate/20211110061152_rename_self_last_comment_at_to_products.rb new file mode 100644 index 00000000000..1dbbe6c5cd5 --- /dev/null +++ b/db/migrate/20211110061152_rename_self_last_comment_at_to_products.rb @@ -0,0 +1,5 @@ +class RenameSelfLastCommentAtToProducts < ActiveRecord::Migration[6.1] + def change + rename_column :products, :self_last_comment_at, :self_last_commented_at + end +end diff --git a/db/schema.rb b/db/schema.rb index 8a6eee6dfb9..b70bb334358 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_23_050713) do +ActiveRecord::Schema.define(version: 2021_11_10_061152) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -315,7 +315,7 @@ t.boolean "wip", default: false, null: false t.datetime "published_at" t.bigint "checker_id" - t.datetime "self_last_comment_at" + t.datetime "self_last_commented_at" t.datetime "mentor_last_comment_at" t.datetime "commented_at" t.index ["commented_at"], name: "index_products_on_commented_at" From 7dd88f237c31d41ce4f7b8b90d7d09d70465a4fd Mon Sep 17 00:00:00 2001 From: IkumaTadokoro Date: Wed, 10 Nov 2021 15:39:18 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Products.mentor=5Flast=5Fcomment=5Fat?= =?UTF-8?q?=E3=82=92mentor=5Flast=5Fcommented=5Fat=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/product.vue | 14 +++++++------- app/models/comment_callbacks.rb | 6 +++--- app/views/api/products/_product.json.jbuilder | 6 +++--- ...03_rename_mentor_last_comment_at_to_products.rb | 5 +++++ db/schema.rb | 4 ++-- 5 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20211110063403_rename_mentor_last_comment_at_to_products.rb diff --git a/app/javascript/product.vue b/app/javascript/product.vue index d93666afa75..da197baac23 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -70,30 +70,30 @@ ) .thread-list-item-meta__item( - v-if='product.self_last_commented_at_date_time && product.mentor_last_comment_at_date_time' + v-if='product.self_last_commented_at_date_time && product.mentor_last_commented_at_date_time' ) time.a-meta( - v-if='product.self_last_commented_at_date_time > product.mentor_last_comment_at_date_time' + v-if='product.self_last_commented_at_date_time > product.mentor_last_commented_at_date_time' ) | 〜 {{ product.self_last_commented_at }}( strong | 提出者 | ) time.a-meta( - v-if='product.self_last_commented_at_date_time < product.mentor_last_comment_at_date_time' + v-if='product.self_last_commented_at_date_time < product.mentor_last_commented_at_date_time' ) - | 〜 {{ product.mentor_last_comment_at }}(メンター) + | 〜 {{ product.mentor_last_commented_at }}(メンター) .thread-list-item-meta__item( - v-else-if='product.self_last_commented_at_date_time || product.mentor_last_comment_at_date_time' + v-else-if='product.self_last_commented_at_date_time || product.mentor_last_commented_at_date_time' ) time.a-meta(v-if='product.self_last_commented_at_date_time') | 〜 {{ product.self_last_commented_at }}( strong | 提出者 | ) - time.a-meta(v-else-if='product.mentor_last_comment_at_date_time') - | 〜 {{ product.mentor_last_comment_at }}(メンター) + time.a-meta(v-else-if='product.mentor_last_commented_at_date_time') + | 〜 {{ product.mentor_last_commented_at }}(メンター) .stamp.stamp-approve(v-if='product.checks.size > 0') h2.stamp__content.is-title 確認済 diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index 11bc84967ab..0a19ee9a7c1 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -34,7 +34,7 @@ def after_destroy(comment) private def reset_last_comment_at(product) - product.mentor_last_comment_at = nil + product.mentor_last_commented_at = nil product.self_last_commented_at = nil end @@ -45,7 +45,7 @@ def delete_last_comment_at(product_id) product.comments.each do |comment| if comment.user.mentor - product.mentor_last_comment_at = comment.updated_at + product.mentor_last_commented_at = comment.updated_at elsif comment.user == product.user product.self_last_commented_at = comment.updated_at end @@ -56,7 +56,7 @@ def delete_last_comment_at(product_id) def update_last_comment_at(comment) product = Product.find(comment.commentable.id) if comment.user.mentor - product.mentor_last_comment_at = comment.updated_at + product.mentor_last_commented_at = comment.updated_at elsif comment.user == product.user product.self_last_commented_at = comment.updated_at end diff --git a/app/views/api/products/_product.json.jbuilder b/app/views/api/products/_product.json.jbuilder index 4db567990dd..4a7dc6a2f63 100644 --- a/app/views/api/products/_product.json.jbuilder +++ b/app/views/api/products/_product.json.jbuilder @@ -22,9 +22,9 @@ if product.self_last_commented_at.present? json.self_last_commented_at_date_time product.self_last_commented_at.to_datetime end -if product.mentor_last_comment_at.present? - json.mentor_last_comment_at l(product.mentor_last_comment_at) - json.mentor_last_comment_at_date_time product.mentor_last_comment_at.to_datetime +if product.mentor_last_commented_at.present? + json.mentor_last_commented_at l(product.mentor_last_commented_at) + json.mentor_last_commented_at_date_time product.mentor_last_commented_at.to_datetime end json.user do diff --git a/db/migrate/20211110063403_rename_mentor_last_comment_at_to_products.rb b/db/migrate/20211110063403_rename_mentor_last_comment_at_to_products.rb new file mode 100644 index 00000000000..1b8f3135169 --- /dev/null +++ b/db/migrate/20211110063403_rename_mentor_last_comment_at_to_products.rb @@ -0,0 +1,5 @@ +class RenameMentorLastCommentAtToProducts < ActiveRecord::Migration[6.1] + def change + rename_column :products, :mentor_last_comment_at, :mentor_last_commented_at + end +end diff --git a/db/schema.rb b/db/schema.rb index b70bb334358..6445ce6949f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_11_10_061152) do +ActiveRecord::Schema.define(version: 2021_11_10_063403) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -316,7 +316,7 @@ t.datetime "published_at" t.bigint "checker_id" t.datetime "self_last_commented_at" - t.datetime "mentor_last_comment_at" + t.datetime "mentor_last_commented_at" t.datetime "commented_at" t.index ["commented_at"], name: "index_products_on_commented_at" t.index ["practice_id"], name: "index_products_on_practice_id" From cb9e4815849630cad0aa72fb9ca563b0fb38c729 Mon Sep 17 00:00:00 2001 From: IkumaTadokoro Date: Wed, 10 Nov 2021 15:45:15 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E5=90=8D=E3=81=8C`*comment=5Fat`=E3=81=AB=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E7=AE=87=E6=89=80=E3=82=92=E3=80=81?= =?UTF-8?q?`*commented=5Fat`=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment_callbacks.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index 0a19ee9a7c1..2db4f509f52 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -11,7 +11,7 @@ def after_create(comment) return unless comment.commentable.instance_of?(Product) - update_last_comment_at(comment) + update_last_commented_at(comment) update_commented_at(comment) delete_product_cache(comment.commentable.id) end @@ -19,29 +19,29 @@ def after_create(comment) def after_update(comment) return unless comment.commentable.instance_of?(Product) - update_last_comment_at(comment) + update_last_commented_at(comment) update_commented_at(comment) end def after_destroy(comment) return unless comment.commentable.instance_of?(Product) - delete_last_comment_at(comment.commentable.id) + delete_last_commented_at(comment.commentable.id) delete_commented_at(comment) delete_product_cache(comment.commentable.id) end private - def reset_last_comment_at(product) + def reset_last_commented_at(product) product.mentor_last_commented_at = nil product.self_last_commented_at = nil end - def delete_last_comment_at(product_id) + def delete_last_commented_at(product_id) product = Product.find(product_id) - reset_last_comment_at(product) + reset_last_commented_at(product) product.comments.each do |comment| if comment.user.mentor @@ -53,7 +53,7 @@ def delete_last_comment_at(product_id) product.save! end - def update_last_comment_at(comment) + def update_last_commented_at(comment) product = Product.find(comment.commentable.id) if comment.user.mentor product.mentor_last_commented_at = comment.updated_at From 7b7f14287da63c6691d5bfb084303cfa5dd884c1 Mon Sep 17 00:00:00 2001 From: IkumaTadokoro Date: Wed, 10 Nov 2021 16:14:01 +0900 Subject: [PATCH 4/4] =?UTF-8?q?prettier=E3=81=AE=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/product.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/javascript/product.vue b/app/javascript/product.vue index da197baac23..489d2b3ce1e 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -92,7 +92,9 @@ strong | 提出者 | ) - time.a-meta(v-else-if='product.mentor_last_commented_at_date_time') + time.a-meta( + v-else-if='product.mentor_last_commented_at_date_time' + ) | 〜 {{ product.mentor_last_commented_at }}(メンター) .stamp.stamp-approve(v-if='product.checks.size > 0')