Skip to content

Commit

Permalink
fix: stored algolia user data (#245)
Browse files Browse the repository at this point in the history
* fix: added "atleast 1 corect answer" in multiple choices questions prompt

* fix: correct answers in multiple choice prompt

* fix: changed userd used to store and use in algolia index
  • Loading branch information
3LL4N authored Dec 8, 2023
1 parent d508fa8 commit 9a13d82
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion apps/nextjs/src/pages/api/algoliaUserHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export const updateUserInAlgolia = async (userData: UsersForAlgolia) => {

const algoliaObject: Partial<UsersForAlgolia> & { objectID: string } = {
...userData,
objectID: userData.id,
objectID: userData.userId,
};

delete algoliaObject.id;
delete algoliaObject.userId;

const index = client.initIndex("users");

Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/functions/randomQuestionsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ export const questionFormatGenerators: {
) => `separator\nQuestion: [Your question here, max ${maxCharsForQuestion} characters]
${generateChoicesPrompt(
numChoices,
)}\nCorrect Answer: Option [Correct option number] ${timeAndPointsPrompt}`,
)}\nCorrect Answer: Option [Correct option number and only 1 correct answer] ${timeAndPointsPrompt}`,

multiselect: (
numChoices = 4,
maxCharsForQuestion = 100,
) => `separator\nQuestion: [Your question here, max ${maxCharsForQuestion} characters]
${generateChoicesPrompt(
numChoices,
)}\nAll Correct Answers: Options [Correct option numbers separated by commas, e.g., 1,3] ${timeAndPointsPrompt}`,
)}\nAll Correct Answers: Options [Correct option numbers separated by commas (e.g., 1,3) and at least one correct answer] ${timeAndPointsPrompt}`,

identification: (maxCharsForQuestion = 100, maxCharsForChoice = 68) =>
`separator\nQuestion: [Your question here, max ${maxCharsForQuestion} characters]\nAnswer: [Your answer here, max ${maxCharsForChoice} characters] ${timeAndPointsPrompt}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export const addAllTestsToAlgolia = async (
};

const parseUsersToAlgolia = async (data: Promise<UsersForAlgolia[]>) => {
const usersAlgoliaRecords = (await data).map(({ id, ...rest }) => ({
objectID: id,
const usersAlgoliaRecords = (await data).map(({ userId, ...rest }) => ({
objectID: userId,
...rest,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ export const deleteReviewerFromAlgolia = async (reviewerId: string) => {
export const updateUserInAlgolia = async (userData: UsersForAlgolia) => {
const algoliaObject: Partial<UsersForAlgolia> & { objectID: string } = {
...userData,
objectID: userData.id,
objectID: userData.userId,
};

delete algoliaObject.id;
delete algoliaObject.userId;

const client = initializeAlgoliaClient();
const index = client.initIndex("users");
Expand Down

0 comments on commit 9a13d82

Please sign in to comment.