From c63d4667e1241c3f4f0670726ce67ee3bcc3c2a8 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Fri, 6 Aug 2021 12:26:22 +0900 Subject: [PATCH 01/18] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AB?= =?UTF-8?q?=E6=8F=90=E5=87=BA=E8=80=85=E6=9C=80=E7=B5=82=E3=82=B3=E3=83=A1?= =?UTF-8?q?=E3=83=B3=E3=83=88=E6=97=A5=E6=99=82=E3=81=A8=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=82=BF=E3=83=BC=E6=9C=80=E7=B5=82=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E6=97=A5=E6=99=82=E3=81=AE=E3=82=AB=E3=83=A9=E3=83=A0?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...column_and_mentor_last_comment_at_column_to_products.rb | 7 +++++++ db/schema.rb | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 db/migrate/20210805061849_add_self_last_comment_at_column_and_mentor_last_comment_at_column_to_products.rb diff --git a/db/migrate/20210805061849_add_self_last_comment_at_column_and_mentor_last_comment_at_column_to_products.rb b/db/migrate/20210805061849_add_self_last_comment_at_column_and_mentor_last_comment_at_column_to_products.rb new file mode 100644 index 00000000000..bb189150783 --- /dev/null +++ b/db/migrate/20210805061849_add_self_last_comment_at_column_and_mentor_last_comment_at_column_to_products.rb @@ -0,0 +1,7 @@ +class AddSelfLastCommentAtColumnAndMentorLastCommentAtColumnToProducts < ActiveRecord::Migration[6.1] + def change + add_column :products, :self_last_comment_at, :datetime + + add_column :products, :mentor_last_comment_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index c463cbf16b5..6cccf3b95bd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -322,6 +322,8 @@ t.boolean "wip", default: false, null: false t.datetime "published_at" t.bigint "checker_id" + t.datetime "self_last_comment_at" + t.datetime "mentor_last_comment_at" t.index ["practice_id"], name: "index_products_on_practice_id" t.index ["user_id", "practice_id"], name: "index_products_on_user_id_and_practice_id", unique: true t.index ["user_id"], name: "index_products_on_user_id" From c18628a78271b840cb405c296ddaab7821cc1035 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Fri, 6 Aug 2021 12:29:32 +0900 Subject: [PATCH 02/18] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E5=BE=8C=E3=81=AB=E6=9C=80=E7=B5=82=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E6=97=A5=E6=99=82=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92CommentCa?= =?UTF-8?q?llbacks=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment.rb | 1 + app/models/comment_callbacks.rb | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 51318f596af..14fb3cc306d 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -8,6 +8,7 @@ class Comment < ApplicationRecord belongs_to :user, touch: true belongs_to :commentable, polymorphic: true after_create CommentCallbacks.new + after_update CommentCallbacks.new after_destroy CommentCallbacks.new alias sender user diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index 188914c63fe..11919a9f8fd 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -10,10 +10,15 @@ def after_create(comment) end return unless comment.commentable.instance_of?(Product) - + update_last_comment_at(comment) delete_product_cache(comment.commentable.id) end + def after_update(comment) + return unless comment.commentable.instance_of?(Product) + update_last_comment_at(comment) + end + def after_destroy(comment) return unless comment.commentable.instance_of?(Product) @@ -22,6 +27,17 @@ def after_destroy(comment) private + 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.save! + elsif comment.user == product.user + product.self_last_comment_at = comment.updated_at + product.save! + end + end + def notify_comment(comment) NotificationFacade.came_comment( comment, From af6224dce11fa099eccf2549c774bd149873c8f1 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Fri, 6 Aug 2021 12:30:55 +0900 Subject: [PATCH 03/18] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E5=80=8B?= =?UTF-8?q?=E5=88=A5=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AB=E6=9C=80=E7=B5=82?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E6=97=A5=E6=99=82=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8C=E3=81=B0=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/products/show.html.slim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/views/products/show.html.slim b/app/views/products/show.html.slim index 75cba5e195b..03897008956 100644 --- a/app/views/products/show.html.slim +++ b/app/views/products/show.html.slim @@ -82,6 +82,21 @@ header.page-header = length | ) + - if @product.self_last_comment_at.present? + .thread-header-metas__meta + .a-date + span.a-date__label + | 提出者最終コメント + time.a-date__value(datetime="#{@product.self_last_comment_at.to_datetime}") + = l @product.self_last_comment_at + + - if @product.mentor_last_comment_at.present? + .thread-header-metas__meta + .a-date + span.a-date__label + | メンター最終コメント + time.a-date__value(datetime="#{@product.mentor_last_comment_at.to_datetime}") + = l @product.mentor_last_comment_at .thread-header__row h1.thread-header-title(class="#{@product.wip? ? 'is-wip' : ''}") - if @product.wip? From 3d468a4d0bd909ceaa554a497b3b8b718331b78a Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Fri, 6 Aug 2021 16:03:28 +0900 Subject: [PATCH 04/18] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AB=E6=9C=80=E7=B5=82?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E6=97=A5=E6=99=82=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8C=E3=81=B0=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/product.vue | 8 ++++++++ app/views/api/products/_product.json.jbuilder | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/javascript/product.vue b/app/javascript/product.vue index 4fd97d3f3a1..b979b093b79 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -45,6 +45,14 @@ ) span.a-meta__label 更新 | {{ product.updated_at }} + .thread-list-item-meta__item(v-if='product.self_last_comment_at_date_time') + time.a-date(datetime='product.self_last_comment_at_date_time') + span.a-date__label 提出者最終コメント + | {{ product.self_last_comment_at }} + .thread-list-item-meta__item(v-if='product.mentor_last_comment_at_date_time') + time.a-date(datetime='product.mentor_last_comment_at_date_time') + span.a-date__label メンター最終コメント + | {{ product.mentor_last_comment_at }} .thread-list-item__row(v-if='product.comments.size > 0') hr.thread-list-item__row-separator diff --git a/app/views/api/products/_product.json.jbuilder b/app/views/api/products/_product.json.jbuilder index 2a8115f3372..8d8e551593f 100644 --- a/app/views/api/products/_product.json.jbuilder +++ b/app/views/api/products/_product.json.jbuilder @@ -17,6 +17,16 @@ 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 +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 +end + json.user do json.partial! "api/users/user", user: product.user end From c7933426a30618e80d79b943a979f98a9a5f09be Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 10 Aug 2021 14:01:47 +0900 Subject: [PATCH 05/18] =?UTF-8?q?rubocop=E3=81=AB=E3=82=88=E3=82=8B?= =?UTF-8?q?=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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index 11919a9f8fd..25279e71ca0 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -10,12 +10,14 @@ def after_create(comment) end return unless comment.commentable.instance_of?(Product) + update_last_comment_at(comment) delete_product_cache(comment.commentable.id) end def after_update(comment) return unless comment.commentable.instance_of?(Product) + update_last_comment_at(comment) end From 289f7fc99fcfde6200d197115a1083626ba06686 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 10 Aug 2021 14:06:08 +0900 Subject: [PATCH 06/18] =?UTF-8?q?products/show=E3=81=AB=E3=81=82=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E7=A9=BA=E7=99=BD=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/products/show.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/products/show.html.slim b/app/views/products/show.html.slim index 03897008956..170cb271fc2 100644 --- a/app/views/products/show.html.slim +++ b/app/views/products/show.html.slim @@ -89,7 +89,7 @@ header.page-header | 提出者最終コメント time.a-date__value(datetime="#{@product.self_last_comment_at.to_datetime}") = l @product.self_last_comment_at - + - if @product.mentor_last_comment_at.present? .thread-header-metas__meta .a-date From b717cbb8469b62a0299e2f8ceee80fcd97d1f71d Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 10 Aug 2021 14:21:02 +0900 Subject: [PATCH 07/18] =?UTF-8?q?prettier=E3=81=A7product.vue=E3=82=92?= =?UTF-8?q?=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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/javascript/product.vue b/app/javascript/product.vue index b979b093b79..8f374ca9f83 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -45,11 +45,15 @@ ) span.a-meta__label 更新 | {{ product.updated_at }} - .thread-list-item-meta__item(v-if='product.self_last_comment_at_date_time') + .thread-list-item-meta__item( + v-if='product.self_last_comment_at_date_time' + ) time.a-date(datetime='product.self_last_comment_at_date_time') span.a-date__label 提出者最終コメント | {{ product.self_last_comment_at }} - .thread-list-item-meta__item(v-if='product.mentor_last_comment_at_date_time') + .thread-list-item-meta__item( + v-if='product.mentor_last_comment_at_date_time' + ) time.a-date(datetime='product.mentor_last_comment_at_date_time') span.a-date__label メンター最終コメント | {{ product.mentor_last_comment_at }} From 27adf337cf77609dfc46d92afd34b6e93b7c0d58 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 10 Aug 2021 14:36:02 +0900 Subject: [PATCH 08/18] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E5=80=8B?= =?UTF-8?q?=E5=88=A5=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=A8=E4=B8=80=E8=A6=A7?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE=E8=A6=8B=E3=81=9F=E7=9B=AE?= =?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 | 8 ++++---- app/views/products/show.html.slim | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/javascript/product.vue b/app/javascript/product.vue index 8f374ca9f83..d9010971b3e 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -48,14 +48,14 @@ .thread-list-item-meta__item( v-if='product.self_last_comment_at_date_time' ) - time.a-date(datetime='product.self_last_comment_at_date_time') - span.a-date__label 提出者最終コメント + time.a-meta(datetime='product.self_last_comment_at_date_time') + span.a-meta__label 提出者最終コメント | {{ product.self_last_comment_at }} .thread-list-item-meta__item( v-if='product.mentor_last_comment_at_date_time' ) - time.a-date(datetime='product.mentor_last_comment_at_date_time') - span.a-date__label メンター最終コメント + time.a-meta(datetime='product.mentor_last_comment_at_date_time') + span.a-meta__label メンター最終コメント | {{ product.mentor_last_comment_at }} .thread-list-item__row(v-if='product.comments.size > 0') diff --git a/app/views/products/show.html.slim b/app/views/products/show.html.slim index 170cb271fc2..4d5ce8a472b 100644 --- a/app/views/products/show.html.slim +++ b/app/views/products/show.html.slim @@ -84,18 +84,18 @@ header.page-header - if @product.self_last_comment_at.present? .thread-header-metas__meta - .a-date - span.a-date__label + .a-meta + span.a-meta__label | 提出者最終コメント - time.a-date__value(datetime="#{@product.self_last_comment_at.to_datetime}") + time.a-meta__value(datetime="#{@product.self_last_comment_at.to_datetime}") = l @product.self_last_comment_at - if @product.mentor_last_comment_at.present? .thread-header-metas__meta - .a-date - span.a-date__label + .a-meta + span.a-meta__label | メンター最終コメント - time.a-date__value(datetime="#{@product.mentor_last_comment_at.to_datetime}") + time.a-meta__value(datetime="#{@product.mentor_last_comment_at.to_datetime}") = l @product.mentor_last_comment_at .thread-header__row h1.thread-header-title(class="#{@product.wip? ? 'is-wip' : ''}") From 1d45737c5eedf689f5be88efecca04f63ed62aae Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 10 Aug 2021 16:48:51 +0900 Subject: [PATCH 09/18] =?UTF-8?q?=E6=8F=90=E5=87=BA=E8=80=85=E3=81=A8?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=82=BF=E3=83=BC=E3=81=AE=E3=82=B3=E3=83=A1?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=AE=E6=9C=80=E6=96=B0=E3=81=AE=E6=96=B9?= =?UTF-8?q?=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4&=E3=83=87=E3=82=B6=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=88=E3=81=86=E3=81=AB=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/product.vue | 19 +++++++++---- app/views/products/show.html.slim | 46 +++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/app/javascript/product.vue b/app/javascript/product.vue index d9010971b3e..8ae38e99291 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -46,16 +46,23 @@ span.a-meta__label 更新 | {{ product.updated_at }} .thread-list-item-meta__item( - v-if='product.self_last_comment_at_date_time' + v-if='product.self_last_comment_at_date_time && product.mentor_last_comment_at_date_time' ) - time.a-meta(datetime='product.self_last_comment_at_date_time') - span.a-meta__label 提出者最終コメント + time.a-meta(v-if='product.self_last_comment_at_date_time > product.mentor_last_comment_at_date_time' datetime='product.self_last_comment_at_date_time') + span.a-meta__label.self_comment 最終コメント(提出者) | {{ product.self_last_comment_at }} + time.a-meta(v-if='product.self_last_comment_at_date_time < product.mentor_last_comment_at_date_time' datetime='product.mentor_last_comment_at_date_time') + span.a-meta__label.mentor_comment 最終コメント(メンター) + | {{ product.mentor_last_comment_at }} + .thread-list-item-meta__item( - v-if='product.mentor_last_comment_at_date_time' + v-else-if='product.self_last_comment_at_date_time || product.mentor_last_comment_at_date_time' ) - time.a-meta(datetime='product.mentor_last_comment_at_date_time') - span.a-meta__label メンター最終コメント + time.a-meta(v-if='product.self_last_comment_at_date_time' datetime='product.self_last_comment_at_date_time') + span.a-meta__label.self_comment 最終コメント(提出者) + | {{ product.self_last_comment_at }} + time.a-meta(v-else-if='product.mentor_last_comment_at_date_time' datetime='product.mentor_last_comment_at_date_time') + span.a-meta__label.mentor_comment 最終コメント(メンター) | {{ product.mentor_last_comment_at }} .thread-list-item__row(v-if='product.comments.size > 0') diff --git a/app/views/products/show.html.slim b/app/views/products/show.html.slim index 4d5ce8a472b..fb8dedff022 100644 --- a/app/views/products/show.html.slim +++ b/app/views/products/show.html.slim @@ -82,21 +82,39 @@ header.page-header = length | ) - - if @product.self_last_comment_at.present? - .thread-header-metas__meta - .a-meta - span.a-meta__label - | 提出者最終コメント - time.a-meta__value(datetime="#{@product.self_last_comment_at.to_datetime}") - = l @product.self_last_comment_at + - if @product.self_last_comment_at.present? && @product.mentor_last_comment_at.present? + - if @product.self_last_comment_at > @product.mentor_last_comment_at + .thread-header-metas__meta + .a-meta.self_comment + span.a-meta__label + | 最終コメント(提出者) + time.a-meta__value(datetime="#{@product.self_last_comment_at.to_datetime}") + = l @product.self_last_comment_at - - if @product.mentor_last_comment_at.present? - .thread-header-metas__meta - .a-meta - span.a-meta__label - | メンター最終コメント - time.a-meta__value(datetime="#{@product.mentor_last_comment_at.to_datetime}") - = l @product.mentor_last_comment_at + - elsif @product.self_last_comment_at < @product.mentor_last_comment_at + .thread-header-metas__meta + .a-meta.mentor_comment + span.a-meta__label + | 最終コメント(メンター) + time.a-meta__value(datetime="#{@product.mentor_last_comment_at.to_datetime}") + = l @product.mentor_last_comment_at + + - elsif @product.self_last_comment_at.present? || @product.mentor_last_comment_at.present? + - if @product.self_last_comment_at.present? + .thread-header-metas__meta + .a-meta.self_comment + span.a-meta__label + | 最終コメント(提出者) + time.a-meta__value(datetime="#{@product.self_last_comment_at.to_datetime}") + = l @product.self_last_comment_at + + - elsif @product.mentor_last_comment_at.present? + .thread-header-metas__meta + .a-meta.mentor_comment + span.a-meta__label + | 最終コメント(メンター) + time.a-meta__value(datetime="#{@product.mentor_last_comment_at.to_datetime}") + = l @product.mentor_last_comment_at .thread-header__row h1.thread-header-title(class="#{@product.wip? ? 'is-wip' : ''}") - if @product.wip? From 6889b3b04517a0f7eac239be748d8b845f919122 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 10 Aug 2021 16:52:47 +0900 Subject: [PATCH 10/18] =?UTF-8?q?prettier=E3=81=A7product.vue=E3=82=92?= =?UTF-8?q?=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 | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/javascript/product.vue b/app/javascript/product.vue index 8ae38e99291..9fadb975880 100644 --- a/app/javascript/product.vue +++ b/app/javascript/product.vue @@ -48,20 +48,32 @@ .thread-list-item-meta__item( v-if='product.self_last_comment_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' datetime='product.self_last_comment_at_date_time') + time.a-meta( + v-if='product.self_last_comment_at_date_time > product.mentor_last_comment_at_date_time', + datetime='product.self_last_comment_at_date_time' + ) span.a-meta__label.self_comment 最終コメント(提出者) | {{ product.self_last_comment_at }} - time.a-meta(v-if='product.self_last_comment_at_date_time < product.mentor_last_comment_at_date_time' datetime='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', + datetime='product.mentor_last_comment_at_date_time' + ) span.a-meta__label.mentor_comment 最終コメント(メンター) | {{ 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' ) - time.a-meta(v-if='product.self_last_comment_at_date_time' datetime='product.self_last_comment_at_date_time') + time.a-meta( + v-if='product.self_last_comment_at_date_time', + datetime='product.self_last_comment_at_date_time' + ) span.a-meta__label.self_comment 最終コメント(提出者) | {{ product.self_last_comment_at }} - time.a-meta(v-else-if='product.mentor_last_comment_at_date_time' datetime='product.mentor_last_comment_at_date_time') + time.a-meta( + v-else-if='product.mentor_last_comment_at_date_time', + datetime='product.mentor_last_comment_at_date_time' + ) span.a-meta__label.mentor_comment 最終コメント(メンター) | {{ product.mentor_last_comment_at }} From 028f745c043c6deb919596ee246b1b8587b0a2c3 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 10 Aug 2021 16:56:45 +0900 Subject: [PATCH 11/18] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E7=A9=BA?= =?UTF-8?q?=E7=99=BD=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 空白があったため削除 --- app/views/products/show.html.slim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/products/show.html.slim b/app/views/products/show.html.slim index fb8dedff022..bd7bae694d9 100644 --- a/app/views/products/show.html.slim +++ b/app/views/products/show.html.slim @@ -114,7 +114,8 @@ header.page-header span.a-meta__label | 最終コメント(メンター) time.a-meta__value(datetime="#{@product.mentor_last_comment_at.to_datetime}") - = l @product.mentor_last_comment_at + = l @product.mentor_last_comment_at + .thread-header__row h1.thread-header-title(class="#{@product.wip? ? 'is-wip' : ''}") - if @product.wip? From e17ca84f641f6880c6b86aa9c605fa0d12fe9059 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 17 Aug 2021 20:03:29 +0900 Subject: [PATCH 12/18] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=8C=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C=E3=81=9F=E6=99=82?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E6=97=A5=E6=99=82=E3=82=92=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment_callbacks.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index 25279e71ca0..df5b5f1cac4 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -23,12 +23,28 @@ def after_update(comment) def after_destroy(comment) return unless comment.commentable.instance_of?(Product) - + delete_last_comment_at(comment.commentable.id) delete_product_cache(comment.commentable.id) end private + def delete_last_comment_at(product_id) + product = Product.find(product_id) + #最終日時をリセットする + product.mentor_last_comment_at = nil + product.self_last_comment_at = nil + #最新日時を上書きする + product.comments.each do |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 + end + end + product.save! + end + def update_last_comment_at(comment) product = Product.find(comment.commentable.id) if comment.user.mentor From eb70568e09e1edc90324325cc84e7a2cb9c13f36 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 17 Aug 2021 20:11:35 +0900 Subject: [PATCH 13/18] =?UTF-8?q?=E6=97=A2=E5=AD=98=E3=81=AE=E6=8F=90?= =?UTF-8?q?=E5=87=BA=E7=89=A9=E3=81=AB=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92?= =?UTF-8?q?=E6=8C=BF=E5=85=A5=E3=81=99=E3=82=8Bdata=5Fmigration=E3=82=B9?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/data/20210816082555_add_last_comment_at.rb | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 db/data/20210816082555_add_last_comment_at.rb diff --git a/db/data/20210816082555_add_last_comment_at.rb b/db/data/20210816082555_add_last_comment_at.rb new file mode 100644 index 00000000000..4133ae3d0b3 --- /dev/null +++ b/db/data/20210816082555_add_last_comment_at.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddLastCommentAt < ActiveRecord::Migration[6.1] + def up + products = Product.where(self_last_comment_at: nil).where(mentor_last_comment_at: nil) + products.each do |product| + next unless product.comments.size.positive? + + product.comments.each do |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 + end + end + product.save! + end + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end From da0fc9c1bbe22735e84315a75ae3f5170cde6858 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Tue, 17 Aug 2021 20:12:06 +0900 Subject: [PATCH 14/18] =?UTF-8?q?rubocop=E3=81=AB=E3=82=88=E3=82=8B?= =?UTF-8?q?=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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/comment_callbacks.rb b/app/models/comment_callbacks.rb index df5b5f1cac4..9c75464c57f 100644 --- a/app/models/comment_callbacks.rb +++ b/app/models/comment_callbacks.rb @@ -23,6 +23,7 @@ def after_update(comment) def after_destroy(comment) return unless comment.commentable.instance_of?(Product) + delete_last_comment_at(comment.commentable.id) delete_product_cache(comment.commentable.id) end @@ -31,10 +32,10 @@ def after_destroy(comment) def delete_last_comment_at(product_id) product = Product.find(product_id) - #最終日時をリセットする + # 最終日時をリセットする product.mentor_last_comment_at = nil product.self_last_comment_at = nil - #最新日時を上書きする + # 最新日時を上書きする product.comments.each do |comment| if comment.user.mentor product.mentor_last_comment_at = comment.updated_at From f7a9190d438fd46c003f60804e78c55f256e76f3 Mon Sep 17 00:00:00 2001 From: kanekodaichi Date: Thu, 19 Aug 2021 00:14:11 +0900 Subject: [PATCH 15/18] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AB?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=81=8C=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E9=9A=9B=E3=81=AB=E6=9C=80=E7=B5=82=E3=82=B3=E3=83=A1?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=8C=E6=9B=B4=E6=96=B0=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=81=8B=E6=A4=9C=E8=A8=BC=E3=81=99=E3=82=8B=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/comments_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/system/comments_test.rb b/test/system/comments_test.rb index 4cc725edf6d..a96f3494dee 100644 --- a/test/system/comments_test.rb +++ b/test/system/comments_test.rb @@ -232,4 +232,29 @@ class CommentsTest < ApplicationSystemTestCase find('#js-new-comment').set('@') assert_selector 'span.mention', text: 'mentor' end + + test 'show last comment at' do + # メンターがコメントする + visit_with_auth "/products/#{products(:product2).id}", 'komagata' + within('.thread-comment-form__form') do + fill_in('new_comment[description]', with: 'メンターがコメント') + end + click_button 'コメントする' + wait_for_vuejs + assert_text 'メンターがコメント' + # 最終コメントがメンターであることを確認 + visit current_url + assert_text '最終コメント(メンター)' + # 提出者がコメントする + visit_with_auth "/products/#{products(:product2).id}", 'kimura' + within('.thread-comment-form__form') do + fill_in('new_comment[description]', with: '提出者がコメント') + end + click_button 'コメントする' + wait_for_vuejs + assert_text '提出者がコメント' + # 最終コメントが提出者であることを確認 + visit current_url + assert_text '最終コメント(提出者)' + end end From b8e39617e7eeaddad0623928e2800a46a303b4ea Mon Sep 17 00:00:00 2001 From: teppei machida Date: Mon, 6 Sep 2021 15:46:27 +0900 Subject: [PATCH 16/18] =?UTF-8?q?=E6=8F=90=E5=87=BA=E7=89=A9=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=81=AB=E3=81=82=E3=82=8B=E6=9C=80=E7=B5=82=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E8=A1=A8=E7=A4=BA=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=81=E6=8F=90=E5=87=BA=E7=89=A9=E5=80=8B=E5=88=A5?= =?UTF-8?q?=E3=81=AE=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E3=81=AE?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=E3=80=81=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stylesheets/atoms/_a-user-name.sass | 1 + .../blocks/thread/_thread-list-item.sass | 17 ++-- app/javascript/comments.vue | 4 +- app/javascript/product.vue | 85 +++++++++---------- app/javascript/report.vue | 2 +- app/views/products/_report.html.slim | 2 +- app/views/products/show.html.slim | 73 +++++----------- app/views/reports/_report.html.slim | 2 +- test/system/comments_test.rb | 25 ------ 9 files changed, 77 insertions(+), 134 deletions(-) diff --git a/app/assets/stylesheets/atoms/_a-user-name.sass b/app/assets/stylesheets/atoms/_a-user-name.sass index dbcdb8a8316..2e9fc209110 100644 --- a/app/assets/stylesheets/atoms/_a-user-name.sass +++ b/app/assets/stylesheets/atoms/_a-user-name.sass @@ -2,6 +2,7 @@ color: $muted-text font-size: .8125rem line-height: 1.4 + white-space: nowrap a.a-user-name +hover-link diff --git a/app/assets/stylesheets/blocks/thread/_thread-list-item.sass b/app/assets/stylesheets/blocks/thread/_thread-list-item.sass index fe731624ded..3ea3f3825de 100644 --- a/app/assets/stylesheets/blocks/thread/_thread-list-item.sass +++ b/app/assets/stylesheets/blocks/thread/_thread-list-item.sass @@ -37,19 +37,15 @@ color: $reversal-text border-color: #b50f38 - .thread-list-item__inner +position(relative) padding-left: 3.75rem +media-breakpoint-down(sm) padding-left: 3rem - .thread-list-item.has-assigned & - +media-breakpoint-up(md) - padding-right: 8.75rem .thread-list-item__assignee +media-breakpoint-up(md) - +position(absolute, right 0, top 0) + +position(absolute, right -.5rem, top -.25rem) width: 8rem +media-breakpoint-down(sm) margin-top: .75rem @@ -118,14 +114,19 @@ opacity: .6 .thread-list-item__row-separator - // TODO resetに移す - border: none - margin-bottom: .25rem border-top: dashed 1px $border + height: 1px + +media-breakpoint-up(md) + +margin(vertical, .5rem) + +media-breakpoint-down(sm) + +margin(vertical, .75rem .25rem) .thread-list-item__row &:not(:first-child) margin-top: .25rem + .thread-list-item.has-assigned &:first-child + +media-breakpoint-up(md) + padding-right: 8.5rem .thread-list-item__show-user-detail +position(absolute, top 0) diff --git a/app/javascript/comments.vue b/app/javascript/comments.vue index a2e4f828e1d..b2f0fec0420 100644 --- a/app/javascript/comments.vue +++ b/app/javascript/comments.vue @@ -1,7 +1,7 @@