diff --git a/apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql b/apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql index 2aed7085..6b37b4ee 100644 --- a/apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql +++ b/apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql @@ -1,8 +1,8 @@ -- AlterTable ALTER TABLE "QuestionsQuestion" ADD COLUMN "contentSearch" TSVECTOR GENERATED ALWAYS AS - to_tsvector('english', coalesce(content, '')) + (to_tsvector('english', coalesce(content, ''))) STORED; -- CreateIndex -CREATE INDEX "QuestionsQuestion_contentSearch_idx" ON "QuestionsQuestion" USING GIN("textSearch"); \ No newline at end of file +CREATE INDEX "QuestionsQuestion_contentSearch_idx" ON "QuestionsQuestion" USING GIN("contentSearch"); \ No newline at end of file diff --git a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx index 0ccd23e4..88024b3e 100644 --- a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx +++ b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx @@ -157,7 +157,7 @@ export default function BaseQuestionCard({ onUpvote={handleUpvote} /> )} -
+
{showAggregateStatistics && ( diff --git a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx index cd767e45..c0b0fb18 100644 --- a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx +++ b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx @@ -200,10 +200,13 @@ export default function ContributeQuestionForm({ {similarQuestions?.map((question) => ( { // eslint-disable-next-line no-console console.log('hi!'); diff --git a/apps/portal/src/server/router/questions-question-router.ts b/apps/portal/src/server/router/questions-question-router.ts index 812172dd..2eb4de14 100644 --- a/apps/portal/src/server/router/questions-question-router.ts +++ b/apps/portal/src/server/router/questions-question-router.ts @@ -209,17 +209,13 @@ export const questionsQuestionRouter = createProtectedRouter() .join(' | '); const relatedQuestions = (await ctx.prisma.$queryRaw` - SELECT * FROM "QuestionsQuestion" - WHERE "contentSearch" @@ to_tsquery(${query}) - ORDER BY ts_rank("contentSearch", to_tsquery(${query})) DESC + SELECT "id", "userId", "content", "createdAt", "updatedAt", "questionType", "lastSeenAt", "upvotes" FROM "QuestionsQuestion" + WHERE + "contentSearch" @@ to_tsquery('english', ${query}) + ORDER BY ts_rank("contentSearch", to_tsquery('english', ${query})) DESC `) as Array; - // Dummy data to make this return something - return await ctx.prisma.questionsQuestion.findMany({ - take: 5, - }); - - // Return relatedQuestions; + return relatedQuestions; }, }) .mutation('create', {