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

fix: caching issue with translate surveys #2288

Merged
merged 3 commits into from
Mar 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion packages/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { env } from "./env";

export const IS_FORMBRICKS_CLOUD = env.IS_FORMBRICKS_CLOUD === "1";
export const REVALIDATION_INTERVAL = 0; //TODO: find a good way to cache and revalidate data when it changes
export const SERVICES_REVALIDATION_INTERVAL = 60 * 30; // 30 minutes
export const SERVICES_REVALIDATION_INTERVAL = 60 * 60 * 3; // 3 hours
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the magic number with a constant to improve code readability and maintainability.

Suggested change
export const SERVICES_REVALIDATION_INTERVAL = 60 * 60 * 3; // 3 hours
const THREE_HOURS_IN_SECONDS = 60 * 60 * 3;
export const SERVICES_REVALIDATION_INTERVAL = THREE_HOURS_IN_SECONDS; // 3 hours

export const MAU_LIMIT = IS_FORMBRICKS_CLOUD ? 9000 : 1000000;

// URLs
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/survey/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export const transformToLegacySurvey = async (
const targetLanguage = languageCode ?? "default";
return reverseTranslateSurvey(survey, targetLanguage);
},
[`transformToLegacySurvey-${survey}`],
[`transformToLegacySurvey-${survey.id}-${languageCode}`],
{
tags: [surveyCache.tag.byId(survey.id)],
revalidate: SERVICES_REVALIDATION_INTERVAL,
Expand Down
Loading