Adding dislikes to comments UI and admin#27700
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis pull request implements comment dislikes across Ghost, introducing a new database table (comment_dislikes), a Bookshelf model, service/controller methods (dislike/undislike/getCommentDislikes), API endpoints and route wiring, serializer and include-list updates, lab feature gating, net-score ordering (likes minus dislikes), frontend state and action handlers with optimistic updates, UI components (DislikeButton, updated LikeButton/LikeCount, CommentMetrics, CommentLikesModal), test fixture and mocked API updates, and schema/exporter/integrity test updates. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
It looks like this PR contains a migration 👀 General requirements
Schema changes
Data changes
|
b2a4556 to
9d94bdf
Compare
There was a problem hiding this comment.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/comments-ui/test/utils/mocked-api.ts (1)
139-150:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFix net-score tie-break direction to match
created_at desc.The branch for
count__net_score desc, created_at desccurrently returns oldest-first on ties.Suggested fix
if (setOrder === 'count__net_score desc, created_at desc') { - // Sort by net score (likes - dislikes, desc) first, then by created_at (asc) + // Sort by net score (likes - dislikes, desc) first, then by created_at (desc) this.comments.sort((a, b) => { const likesDiff = (b.count.likes - b.count.dislikes) - (a.count.likes - a.count.dislikes); if (likesDiff !== 0) { return likesDiff; } const aDate = new Date(a.created_at).getTime(); const bDate = new Date(b.created_at).getTime(); - return aDate - bDate; // For the rest, sort by date asc + return bDate - aDate; // For the rest, sort by date desc }); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/comments-ui/test/utils/mocked-api.ts` around lines 139 - 150, The tie-breaker for the branch handling "count__net_score desc, created_at desc" currently sorts by created_at ascending; in the sort callback inside the branch where setOrder === 'count__net_score desc, created_at desc' (the this.comments.sort(...) block), invert the date comparison so that when net-score ties occur the more recent comment comes first (use bDate - aDate instead of aDate - bDate) to implement created_at desc.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/comments-ui/src/actions.ts`:
- Around line 273-286: The optimistic rollback for dislike doesn't restore a
previously liked state; update updateCommentDislikeState to use the passed-in
comment.wasLiked flag when toggling disliked to properly restore liked and
adjust likes count. Specifically, in the block that finds the reply by id, set
liked to comment.disliked ? false : (comment.wasLiked ?? r.liked), and when
computing count.likes do: if (comment.disliked) decrement dislikes and if
(!comment.disliked && comment.wasLiked) increment likes; mirror the same logic
in the other similar handlers noted (the blocks around lines 296-303 and
337-345) so rollback restores liked=true and increments likes when wasLiked was
true.
- Around line 231-244: In updateCommentLikeState, the optimistic like update
clears a prior dislike but the rollback only restores liked and likes count;
change the logic so you capture and restore the original r.disliked and
r.count.dislikes when rolling back. Concretely: when building the optimistic
reply object in updateCommentLikeState (and the analogous blocks at the other
occurrences mentioned), compute new disliked and dislikes using comment.liked
and comment.wasDisliked but also keep the prior values (r.disliked and
r.count.dislikes) available and use them to restore both disliked and dislikes
in the rollback branch so the UI fully returns to the previous state.
In `@apps/comments-ui/src/components/content/buttons/like-button.tsx`:
- Around line 119-133: The dislike button is icon-only and lacks an accessible
name; update the button rendered in the like-button component to provide an
accessible label (e.g., add aria-label="Dislike" or aria-labelledby pointing to
a visually-hidden label) so screen readers can identify it; modify the JSX where
the <button ... onClick={toggleDislike}> and the <ThumbsDownIcon ... /> are
defined to include the aria attribute (or add a hidden <span> with an id and use
aria-labelledby) and ensure tests/data-testid remain unchanged.
In `@apps/comments-ui/src/components/content/forms/sorting-form.tsx`:
- Around line 9-15: selectedOption is only set once via useState(order) so it
can get out of sync when order or the computed bestOrder (depends on
labs?.commentDislikes) changes; add a useEffect that watches order and bestOrder
and calls setSelectedOption(order) (or setSelectedOption(bestOrder) if you
compute order from labs earlier) to keep the dropdown label in sync; locate the
state variables selectedOption/setSelectedOption, the order prop/context, and
the bestOrder constant in sorting-form.tsx and update them with this useEffect
so changes to order or labs immediately reflect in the dropdown.
In `@apps/posts/src/views/comments/components/comment-metrics.tsx`:
- Around line 124-135: The likes/dislikes icon-only buttons in
comment-metrics.tsx lack accessible names; update the two icon buttons (the one
using LucideIcon.ThumbsUp and the corresponding dislikes button) to include an
explicit accessible label (e.g., aria-label or aria-labelledby) such as "Show
likes" / "Show dislikes" or "Open likes modal" / "Open dislikes modal" so screen
readers announce their purpose; ensure the aria attribute is added to the same
button elements that call setLikesModalDefaultTab/setLikesModalOpen (and the
analogous handlers for dislikes) without changing the click behavior.
In
`@ghost/core/core/server/data/migrations/versions/6.40/2026-04-22-00-00-add-comment-dislikes-table.js`:
- Around line 3-9: Add a DB-level unique constraint/index to enforce one dislike
per member per comment: modify the migration that creates the comment_dislikes
table so the pair (comment_id, member_id) is uniquely constrained (e.g., add a
composite unique index on comment_dislikes for comment_id and member_id), keep
the existing fields (id, comment_id, member_id, created_at, updated_at), and add
the corresponding index removal in the down/rollback path; reference the table
name "comment_dislikes" and the columns "comment_id" and "member_id" when
implementing the change.
In `@ghost/core/core/server/services/comments/comments-service.js`:
- Around line 142-154: Wrap the mutual-exclusivity read/delete/add sequence in a
single DB transaction so concurrent like/dislike requests cannot interleave:
start a transaction, pass the transaction object via options to
CommentDislike.findOne, CommentDislike.destroy and the subsequent create (e.g.,
the create on CommentLike/CommentDislike used in this flow), perform the
find/delete inside that transaction (optionally using a row lock / FOR UPDATE if
supported), then create the new reaction and commit; apply the same
transactional change to the other exclusivity block around lines 211-223 so both
flows run atomically.
---
Outside diff comments:
In `@apps/comments-ui/test/utils/mocked-api.ts`:
- Around line 139-150: The tie-breaker for the branch handling "count__net_score
desc, created_at desc" currently sorts by created_at ascending; in the sort
callback inside the branch where setOrder === 'count__net_score desc, created_at
desc' (the this.comments.sort(...) block), invert the date comparison so that
when net-score ties occur the more recent comment comes first (use bDate - aDate
instead of aDate - bDate) to implement created_at desc.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7ef76a29-7e11-4b75-abf1-4dda89de37bb
⛔ Files ignored due to path filters (4)
apps/comments-ui/src/images/icons/thumbs-down.svgis excluded by!**/*.svgapps/comments-ui/src/images/icons/thumbs-up.svgis excluded by!**/*.svgghost/core/test/e2e-api/admin/__snapshots__/comments.test.js.snapis excluded by!**/*.snapghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snapis excluded by!**/*.snap
📒 Files selected for processing (36)
apps/admin-x-framework/src/api/comments.tsapps/admin-x-settings/src/components/settings/advanced/labs/private-features.tsxapps/comments-ui/package.jsonapps/comments-ui/src/actions.tsapps/comments-ui/src/app-context.tsapps/comments-ui/src/app.tsxapps/comments-ui/src/components/content/buttons/like-button.tsxapps/comments-ui/src/components/content/buttons/like-count.tsxapps/comments-ui/src/components/content/comment.tsxapps/comments-ui/src/components/content/forms/sorting-form.tsxapps/comments-ui/src/utils/api.tsapps/comments-ui/test/utils/fixtures.tsapps/comments-ui/test/utils/mocked-api.tsapps/posts/src/views/comments/comments.tsxapps/posts/src/views/comments/components/comment-likes-modal.tsxapps/posts/src/views/comments/components/comment-metrics.tsxapps/posts/src/views/comments/components/comment-thread-list.tsxapps/posts/src/views/comments/components/comment-thread-sidebar.tsxapps/posts/src/views/comments/components/comments-list.tsxghost/core/core/server/api/endpoints/comment-dislikes.jsghost/core/core/server/api/endpoints/comment-replies.jsghost/core/core/server/api/endpoints/comments-members.jsghost/core/core/server/api/endpoints/index.jsghost/core/core/server/api/endpoints/utils/serializers/output/mappers/comments.jsghost/core/core/server/data/migrations/versions/6.40/2026-04-22-00-00-add-comment-dislikes-table.jsghost/core/core/server/data/schema/schema.jsghost/core/core/server/models/comment-dislike.jsghost/core/core/server/models/comment.jsghost/core/core/server/models/index.jsghost/core/core/server/services/comments/comments-controller.jsghost/core/core/server/services/comments/comments-service.jsghost/core/core/server/web/api/endpoints/admin/routes.jsghost/core/core/server/web/comments/routes.jsghost/core/core/shared/labs.jsghost/core/test/integration/exporter/exporter.test.jsghost/core/test/unit/server/data/schema/integrity.test.js
| const [selectedOption, setSelectedOption] = useState(order); | ||
| const dropdownRef = useRef<HTMLDivElement>(null); | ||
| const bestOrder = labs?.commentDislikes ? 'count__net_score desc, created_at desc' : 'count__likes desc, created_at desc'; | ||
|
|
||
| const options = [ | ||
| {value: 'count__likes desc, created_at desc', label: t('Best')}, | ||
| {value: bestOrder, label: t('Best')}, | ||
| {value: 'created_at desc', label: t('Newest')}, |
There was a problem hiding this comment.
Keep selectedOption synchronized with context order.
selectedOption is only initialized once. When order changes later (e.g., after labs-driven default order is applied), the dropdown label can desync.
Suggested fix
const [selectedOption, setSelectedOption] = useState(order);
@@
const options = [
{value: bestOrder, label: t('Best')},
{value: 'created_at desc', label: t('Newest')},
{value: 'created_at asc', label: t('Oldest')}
];
+
+ useEffect(() => {
+ setSelectedOption(order);
+ }, [order]);Also applies to: 25-25
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/comments-ui/src/components/content/forms/sorting-form.tsx` around lines
9 - 15, selectedOption is only set once via useState(order) so it can get out of
sync when order or the computed bestOrder (depends on labs?.commentDislikes)
changes; add a useEffect that watches order and bestOrder and calls
setSelectedOption(order) (or setSelectedOption(bestOrder) if you compute order
from labs earlier) to keep the dropdown label in sync; locate the state
variables selectedOption/setSelectedOption, the order prop/context, and the
bestOrder constant in sorting-form.tsx and update them with this useEffect so
changes to order or labs immediately reflect in the dropdown.
| module.exports = addTable('comment_dislikes', { | ||
| id: {type: 'string', maxlength: 24, nullable: false, primary: true}, | ||
| comment_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'comments.id', cascadeDelete: true}, | ||
| member_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'members.id', cascadeDelete: true}, | ||
| created_at: {type: 'dateTime', nullable: false}, | ||
| updated_at: {type: 'dateTime', nullable: false} | ||
| }); |
There was a problem hiding this comment.
Enforce one dislike per member/comment at the database layer.
The current definition allows duplicate dislikes for the same (comment_id, member_id) under concurrent requests, which can inflate counts and break reaction semantics.
💡 Suggested fix
module.exports = addTable('comment_dislikes', {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
comment_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'comments.id', cascadeDelete: true},
member_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'members.id', cascadeDelete: true},
created_at: {type: 'dateTime', nullable: false},
- updated_at: {type: 'dateTime', nullable: false}
+ updated_at: {type: 'dateTime', nullable: false},
+ '@@UNIQUE_CONSTRAINTS@@': [
+ ['comment_id', 'member_id']
+ ]
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| module.exports = addTable('comment_dislikes', { | |
| id: {type: 'string', maxlength: 24, nullable: false, primary: true}, | |
| comment_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'comments.id', cascadeDelete: true}, | |
| member_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'members.id', cascadeDelete: true}, | |
| created_at: {type: 'dateTime', nullable: false}, | |
| updated_at: {type: 'dateTime', nullable: false} | |
| }); | |
| module.exports = addTable('comment_dislikes', { | |
| id: {type: 'string', maxlength: 24, nullable: false, primary: true}, | |
| comment_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'comments.id', cascadeDelete: true}, | |
| member_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'members.id', cascadeDelete: true}, | |
| created_at: {type: 'dateTime', nullable: false}, | |
| updated_at: {type: 'dateTime', nullable: false}, | |
| '@@UNIQUE_CONSTRAINTS@@': [ | |
| ['comment_id', 'member_id'] | |
| ] | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@ghost/core/core/server/data/migrations/versions/6.40/2026-04-22-00-00-add-comment-dislikes-table.js`
around lines 3 - 9, Add a DB-level unique constraint/index to enforce one
dislike per member per comment: modify the migration that creates the
comment_dislikes table so the pair (comment_id, member_id) is uniquely
constrained (e.g., add a composite unique index on comment_dislikes for
comment_id and member_id), keep the existing fields (id, comment_id, member_id,
created_at, updated_at), and add the corresponding index removal in the
down/rollback path; reference the table name "comment_dislikes" and the columns
"comment_id" and "member_id" when implementing the change.
| // Remove any existing dislike (mutual exclusivity). This must always | ||
| // run so disabling and re-enabling the feature flag cannot leave a | ||
| // member with both reactions. | ||
| const existingDislike = await this.models.CommentDislike.findOne(data, options); | ||
| if (existingDislike) { | ||
| await this.models.CommentDislike.destroy({ | ||
| ...options, | ||
| destroyBy: { | ||
| member_id: memberModel.id, | ||
| comment_id: commentId | ||
| } | ||
| }); | ||
| } |
There was a problem hiding this comment.
Make reaction exclusivity atomic.
These read/delete/add steps can interleave across concurrent like/dislike requests, leaving both reactions stored for one member/comment. Wrap the exclusivity flow in a single transaction and perform checks/mutations inside that transaction.
Also applies to: 211-223
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ghost/core/core/server/services/comments/comments-service.js` around lines
142 - 154, Wrap the mutual-exclusivity read/delete/add sequence in a single DB
transaction so concurrent like/dislike requests cannot interleave: start a
transaction, pass the transaction object via options to CommentDislike.findOne,
CommentDislike.destroy and the subsequent create (e.g., the create on
CommentLike/CommentDislike used in this flow), perform the find/delete inside
that transaction (optionally using a row lock / FOR UPDATE if supported), then
create the new reaction and commit; apply the same transactional change to the
other exclusivity block around lines 211-223 so both flows run atomically.
No ref WIP
7599537 to
956c51e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/comments-ui/test/utils/fixtures.ts`:
- Around line 61-64: The reply fixture builder buildReply currently allows
override.count to replace the entire count object, causing count.dislikes to be
lost when tests pass partial counts; update buildReply to merge the default
count with override.count (same approach used in buildComment) so defaults.likes
and defaults.dislikes are preserved (e.g., compute mergedCount =
{...defaultCount, ...override.count} and use that merged object when
constructing the reply), and apply the same merge logic for the other affected
spot noted around line 71.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9a75975b-7f3c-4c38-852d-51611bb3ca13
⛔ Files ignored due to path filters (5)
apps/comments-ui/src/images/icons/thumbs-down.svgis excluded by!**/*.svgapps/comments-ui/src/images/icons/thumbs-up.svgis excluded by!**/*.svgghost/core/test/e2e-api/admin/__snapshots__/comments.test.js.snapis excluded by!**/*.snapghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snapis excluded by!**/*.snapghost/core/test/e2e-api/members-comments/__snapshots__/comments.test.js.snapis excluded by!**/*.snap
📒 Files selected for processing (35)
apps/admin-x-framework/src/api/comments.tsapps/admin-x-settings/src/components/settings/advanced/labs/private-features.tsxapps/comments-ui/src/actions.tsapps/comments-ui/src/app-context.tsapps/comments-ui/src/app.tsxapps/comments-ui/src/components/content/buttons/like-button.tsxapps/comments-ui/src/components/content/buttons/like-count.tsxapps/comments-ui/src/components/content/comment.tsxapps/comments-ui/src/components/content/forms/sorting-form.tsxapps/comments-ui/src/utils/api.tsapps/comments-ui/test/utils/fixtures.tsapps/comments-ui/test/utils/mocked-api.tsapps/posts/src/views/comments/comments.tsxapps/posts/src/views/comments/components/comment-likes-modal.tsxapps/posts/src/views/comments/components/comment-metrics.tsxapps/posts/src/views/comments/components/comment-thread-list.tsxapps/posts/src/views/comments/components/comment-thread-sidebar.tsxapps/posts/src/views/comments/components/comments-list.tsxghost/core/core/server/api/endpoints/comment-dislikes.jsghost/core/core/server/api/endpoints/comment-replies.jsghost/core/core/server/api/endpoints/comments-members.jsghost/core/core/server/api/endpoints/index.jsghost/core/core/server/api/endpoints/utils/serializers/output/mappers/comments.jsghost/core/core/server/data/migrations/versions/6.40/2026-04-22-00-00-add-comment-dislikes-table.jsghost/core/core/server/data/schema/schema.jsghost/core/core/server/models/comment-dislike.jsghost/core/core/server/models/comment.jsghost/core/core/server/models/index.jsghost/core/core/server/services/comments/comments-controller.jsghost/core/core/server/services/comments/comments-service.jsghost/core/core/server/web/api/endpoints/admin/routes.jsghost/core/core/server/web/comments/routes.jsghost/core/core/shared/labs.jsghost/core/test/integration/exporter/exporter.test.jsghost/core/test/unit/server/data/schema/integrity.test.js
✅ Files skipped from review due to trivial changes (1)
- apps/admin-x-settings/src/components/settings/advanced/labs/private-features.tsx
🚧 Files skipped from review as they are similar to previous changes (28)
- ghost/core/core/shared/labs.js
- apps/comments-ui/src/app-context.ts
- apps/comments-ui/src/components/content/comment.tsx
- ghost/core/test/integration/exporter/exporter.test.js
- ghost/core/core/server/data/migrations/versions/6.40/2026-04-22-00-00-add-comment-dislikes-table.js
- ghost/core/core/server/api/endpoints/index.js
- ghost/core/core/server/models/comment-dislike.js
- ghost/core/core/server/services/comments/comments-controller.js
- ghost/core/core/server/web/comments/routes.js
- ghost/core/core/server/data/schema/schema.js
- apps/posts/src/views/comments/components/comment-thread-list.tsx
- apps/posts/src/views/comments/components/comments-list.tsx
- apps/comments-ui/src/utils/api.ts
- apps/posts/src/views/comments/components/comment-thread-sidebar.tsx
- ghost/core/core/server/api/endpoints/comment-replies.js
- apps/posts/src/views/comments/comments.tsx
- ghost/core/core/server/web/api/endpoints/admin/routes.js
- apps/posts/src/views/comments/components/comment-metrics.tsx
- apps/comments-ui/src/components/content/forms/sorting-form.tsx
- apps/comments-ui/test/utils/mocked-api.ts
- ghost/core/core/server/api/endpoints/utils/serializers/output/mappers/comments.js
- apps/admin-x-framework/src/api/comments.ts
- ghost/core/core/server/api/endpoints/comment-dislikes.js
- apps/comments-ui/src/components/content/buttons/like-button.tsx
- apps/posts/src/views/comments/components/comment-likes-modal.tsx
- apps/comments-ui/src/app.tsx
- apps/comments-ui/src/components/content/buttons/like-count.tsx
- ghost/core/core/server/services/comments/comments-service.js
| count: { | ||
| likes: 0 | ||
| likes: 0, | ||
| dislikes: 0 | ||
| }, |
There was a problem hiding this comment.
Preserve default count.dislikes when overriding reply fixtures.
buildReply({...override}) currently lets override.count replace the whole count object, so dislikes can disappear when tests pass partial counts (e.g. {count: {likes: 1}}). Merge override.count into defaults like buildComment does.
Proposed fix
export function buildReply(override: any = {}) {
return {
id: ObjectId().toString(),
html: '<p>Empty</p>',
count: {
likes: 0,
- dislikes: 0
+ dislikes: 0,
+ ...override.count
},
liked: false,
disliked: false,
created_at: '2022-08-11T09:26:34.000Z',
edited_at: null,
member: buildMember(),
status: 'published',
- ...override
+ ...override
};
}Also applies to: 71-71
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/comments-ui/test/utils/fixtures.ts` around lines 61 - 64, The reply
fixture builder buildReply currently allows override.count to replace the entire
count object, causing count.dislikes to be lost when tests pass partial counts;
update buildReply to merge the default count with override.count (same approach
used in buildComment) so defaults.likes and defaults.dislikes are preserved
(e.g., compute mergedCount = {...defaultCount, ...override.count} and use that
merged object when constructing the reply), and apply the same merge logic for
the other affected spot noted around line 71.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #27700 +/- ##
==========================================
- Coverage 73.79% 73.75% -0.05%
==========================================
Files 1522 1525 +3
Lines 128738 129308 +570
Branches 15450 15498 +48
==========================================
+ Hits 95002 95368 +366
- Misses 32778 33005 +227
+ Partials 958 935 -23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jonatansberg
left a comment
There was a problem hiding this comment.
Overall, I think this looks pretty good. One architectural question that I think we should dig into before proceeding.
The rabbit comment about UI accessibility should also be addressed.
| module.exports = addTable('comment_dislikes', { | ||
| id: {type: 'string', maxlength: 24, nullable: false, primary: true}, | ||
| comment_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'comments.id', cascadeDelete: true}, | ||
| member_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'members.id', cascadeDelete: true}, | ||
| created_at: {type: 'dateTime', nullable: false}, | ||
| updated_at: {type: 'dateTime', nullable: false} | ||
| }); |
There was a problem hiding this comment.
Have we considered modeling this as another field on the like rather than a separate table? Right now, the way we delete existing (dis)likes if you click both buttons is racy, meaning you can end up both liking and disliking a given comment. While there are other ways to solve for that, just keeping it as one row in the same table makes it way easier.
It would also mean we can do a single aggregation to get the net score, which should be a slight performance benefit.
Let's chat about it in the mob.
Ref https://linear.app/ghost/issue/BER-3549/create-comment-dislikes-private-lab-flag https://linear.app/ghost/issue/BER-3550/adjust-ui-for-liking-and-disliking-comments-in-comments-ui https://linear.app/ghost/issue/BER-3551/adjust-ui-for-comments-in-admin https://linear.app/ghost/issue/BER-3553/and-comment-dislikes-modal-to-admin
Adds downvotes/dislikes to comments behind the commentDislikes feature flag. Also adds a measure for these to Admin in the Comments list.