Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing indices for dsaReports to INDEXES.md #4432

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions INDEXES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ The goal of this document is to date-mark the indexes you add to support the cha

If you are releasing, you can use this readme to check all the indexes prior to the release you are deploying and have a good idea of what indexes you might need to deploy to Mongo along with your release of a new Coral Docker image to kubernetes.

## 2023-11-24

```
db.dsaReports.createIndex({ tenantID: 1, id: 1 }, { unique: true });
```

- This index creates the uniqueness constraint for the `tenantID` and `id` fields on the `dsaReports`

```
db.dsaReports.createIndex({ status: 1, createdAt: 1, tenantID: 1 });
db.dsaReports.createIndex({ referenceID: 1, tenantID: 1 });
db.dsaReports.createIndex({ submissionID: 1, tenantID: 1 });
```

- These indices are used to optimize pagination of `dsaReports` and allow them to be retrieved by their `referenceID`, `submissionID` efficiently.

## 2023-10-18

```
Expand Down
31 changes: 31 additions & 0 deletions client/src/core/client/admin/routes/Reports/ReportedComment.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,34 @@
font-weight: var(--font-weight-primary-regular);
white-space: pre-wrap;
}

.commentReported {
padding-top: calc(var(--spacing-1) / 2);
padding-bottom: calc(var(--spacing-1) / 2);
padding-right: calc(var(--spacing-1));
padding-left: calc(var(--spacing-1));

background-color: var(--palette-error-500);

border-color: var(--palette-error-500);
border-style: solid;
border-radius: 3px;

color: var(--palette-text-000);

text-transform: uppercase;

font-size: var(--font-size-1);
font-weight: var(--font-weight-primary-regular);
font-family: var(--font-family-primary);

margin-right: var(--spacing-1);
}

.commentNotAvailableInStream {
font-size: var(--font-size-1);
font-weight: var(--font-weight-primary-regular);
font-family: var(--font-family-primary);

color: var(--palette-grey-400);
}
53 changes: 36 additions & 17 deletions client/src/core/client/admin/routes/Reports/ReportedComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getURLWithCommentID,
} from "coral-framework/helpers";
import { withFragmentContainer } from "coral-framework/lib/relay";
import { GQLCOMMENT_STATUS } from "coral-framework/schema";
import {
Button,
Flex,
Expand Down Expand Up @@ -130,28 +131,45 @@ const ReportedComment: FunctionComponent<Props> = ({
</div>
</Flex>
<Flex>
<Flex marginTop={2} marginRight={3}>
<Localized id="reports-singleReport-comment-viewCommentStream">
<Button
variant="text"
uppercase={false}
color="mono"
to={getURLWithCommentID(
comment.story.url,
comment.id
)}
target="_blank"
>
View comment in stream
</Button>
</Localized>
</Flex>
{comment.status === GQLCOMMENT_STATUS.REJECTED ? (
<Flex marginTop={2} marginRight={3}>
<Flex alignItems="center" justifyContent="flex-start">
<Localized id="reports-singleReport-comment-rejected">
<div className={styles.commentReported}>
Rejected
</div>
</Localized>
<Localized id="reports-singleReport-comment-unavailableInStream">
<div className={styles.commentNotAvailableInStream}>
Unavailable in stream
</div>
</Localized>
</Flex>
</Flex>
) : (
<Flex marginTop={2} marginRight={3}>
<Localized id="reports-singleReport-comment-viewCommentStream">
<Button
variant="text"
uppercase={false}
color="regular"
to={getURLWithCommentID(
comment.story.url,
comment.id
)}
target="_blank"
>
View comment in stream
</Button>
</Localized>
</Flex>
)}
<Flex marginTop={2}>
<Localized id="reports-singleReport-comment-viewCommentModeration">
<Button
variant="text"
uppercase={false}
color="mono"
color="regular"
target="_blank"
to={getModerationLink({
commentID: comment.id,
Expand Down Expand Up @@ -201,6 +219,7 @@ const enhanced = withFragmentContainer<Props>({
title
}
}
status
...CommentAuthorContainer_comment
...MediaContainer_comment
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import userEvent from "@testing-library/user-event";

import { pureMerge } from "coral-common/common/lib/utils";
import {
GQLCOMMENT_STATUS,
GQLDSAReportDecisionLegality,
GQLDSAReportHistoryType,
GQLDSAReportStatus,
Expand All @@ -25,7 +26,8 @@ beforeEach(async () => {
});

const createTestRenderer = async (
params: CreateTestRendererParams<GQLResolver> = {}
params: CreateTestRendererParams<GQLResolver> = {},
commentStatus?: GQLCOMMENT_STATUS
) => {
const { context } = createContext({
...params,
Expand All @@ -34,7 +36,17 @@ const createTestRenderer = async (
Query: {
settings: () => settings,
viewer: () => adminViewer,
dsaReport: () => dsaReports[0],
dsaReport: () => {
return {
...dsaReports[0],
comment: commentStatus
? {
...dsaReports[0].comment,
status: commentStatus,
}
: dsaReports[0].comment,
};
},
},
Mutation: {
addDSAReportNote: ({ variables }) => {
Expand Down Expand Up @@ -251,3 +263,20 @@ it("can make a legality decision on a report", async () => {
)
);
});

it("stream link is unavailable when comment is already rejected", async () => {
const { container } = await createTestRenderer(
undefined,
GQLCOMMENT_STATUS.REJECTED
);

expect(await within(container).findByText("Rejected"));
expect(await within(container).findByText("Unavailable in stream"));

expect(
within(container).getByRole("link", { name: "View comment in moderation" })
).toHaveProperty(
"href",
"http://localhost/admin/moderate/comment/comment-regular-0"
);
});
2 changes: 2 additions & 0 deletions locales/en-US/admin.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,8 @@ reports-singleReport-comment-deleted = This comment is no longer available. The
reports-singleReport-comment-edited = (edited)
reports-singleReport-comment-viewCommentStream = View comment in stream
reports-singleReport-comment-viewCommentModeration = View comment in moderation
reports-singleReport-comment-rejected = Rejected
reports-singleReport-comment-unavailableInStream = Unavailable in stream
reports-singleReport-commentOn = Comment on
reports-singleReport-history = History
reports-singleReport-history-reportSubmitted = Illegal content report submitted
Expand Down
Loading