Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Jun 24, 2024
1 parent 6f75058 commit 0aed9e5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
45 changes: 27 additions & 18 deletions src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { assertUser, getContentDefaultStatus } from 'util/user';
import FeedbackVote from 'graphql/models/FeedbackVote';
import ArticleReply from 'graphql/models/ArticleReply';

import type { Article, ArticleReply as ArticleReplyType } from 'rumors-db/schema/articles';
import type {
Article,
ArticleReply as ArticleReplyType,
} from 'rumors-db/schema/articles';
import type { ArticleReplyFeedback } from 'rumors-db/schema/articlereplyfeedbacks';
import type { Reply } from 'rumors-db/schema/replies';

Expand Down Expand Up @@ -105,7 +108,17 @@ export default {
},
async resolve(
rootValue,

Check failure on line 110 in src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Parameter 'rootValue' implicitly has an 'any' type.

Check failure on line 110 in src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Parameter 'rootValue' implicitly has an 'any' type.
{ articleId, replyId, vote, comment },
{
articleId,
replyId,
vote,
comment,
}: {
articleId: string;
replyId: string;
vote: 1 | 0 | -1;
comment?: string | null;
},
{ user, loaders }

Check failure on line 122 in src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Binding element 'user' implicitly has an 'any' type.

Check failure on line 122 in src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Binding element 'loaders' implicitly has an 'any' type.

Check failure on line 122 in src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Binding element 'user' implicitly has an 'any' type.

Check failure on line 122 in src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Binding element 'loaders' implicitly has an 'any' type.
) {
assertUser(user);
Expand Down Expand Up @@ -152,23 +165,19 @@ export default {
// Fill in reply & article reply author ID
//

const [
{ userId: replyUserId },
article,
] = await loaders.docLoader.loadMany([
{
index: 'replies',
id: replyId,
},
{
index: 'articles',
id: articleId,
},
]) as [Reply, Article];
const [{ userId: replyUserId }, article] =
(await loaders.docLoader.loadMany([
{
index: 'replies',
id: replyId,
},
{
index: 'articles',
id: articleId,
},
])) as [Reply, Article];

const ar = article.articleReplies.find(
ar => ar.replyId === replyId
);
const ar = article.articleReplies.find((ar) => ar.replyId === replyId);

// Make typescript happy
if (!ar) {
Expand Down
17 changes: 14 additions & 3 deletions src/scripts/blockUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ async function processArticleReplies(userId: string) {
},
};

const articleRepliesToProcess: Array<Article['articleReplies'][0] & {articleId: string}> = [];
const articleRepliesToProcess: Array<
Article['articleReplies'][0] & { articleId: string }
> = [];
for await (const {
_id,
_source: { articleReplies },
Expand Down Expand Up @@ -221,7 +223,10 @@ async function processArticleReplyFeedbacks(userId: string) {

for await (const {
_source: { articleId, replyId },
} of getAllDocs<ArticleReplyFeedback>('articlereplyfeedbacks', NORMAL_FEEDBACK_QUERY)) {
} of getAllDocs<ArticleReplyFeedback>(
'articlereplyfeedbacks',
NORMAL_FEEDBACK_QUERY
)) {
articleReplyIdsWithNormalFeedbacks.push({ articleId, replyId });
}

Expand Down Expand Up @@ -309,7 +314,13 @@ async function processArticles(userId: string) {
console.log('Article status update result', updateByQueryResult);
}

async function main({ userId, blockedReason }: { userId: string; blockedReason: string }) {
async function main({
userId,
blockedReason,
}: {
userId: string;
blockedReason: string;
}) {
await writeBlockedReasonToUser(userId, blockedReason);
await processArticles(userId);
await processReplyRequests(userId);
Expand Down

0 comments on commit 0aed9e5

Please sign in to comment.