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

chore: roulout expertice in profile #10

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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
28 changes: 20 additions & 8 deletions src/modules/profile/functions/getProfileServerSideProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const getProfileServerSideProps = withServerUtils(async (context: GetServ

let shouldUseProvider: boolean = false;
let shouldUseUser: boolean = false;
let shouldUseExpertice: boolean = false;
try {
const growthbookContext = getServerSideGrowthBookContext(context.req as NextApiRequest);
const growthbook = new GrowthBook(growthbookContext);
Expand All @@ -84,6 +85,16 @@ export const getProfileServerSideProps = withServerUtils(async (context: GetServ
(center: any) => center.center_type === 1 && usersApiDoctorCitiesList.cities?.includes(center.city_en_slug),
) ||
usersApiDoctorCitiesList.cities?.includes('*');

//Expertice Api
const experticeApiDoctorList = growthbook.getFeatureValue('profile:expertises-api|doctor-list', { slugs: [''] });
const experticeApiCitiesList = growthbook.getFeatureValue('profile:expertises-api|cities', { cities: [''] });
shouldUseExpertice =
newApiFeatureFlaggingCondition(experticeApiDoctorList.slugs, slugFormmated) ||
fullProfileData.centers.some(
(center: any) => center.center_type === 1 && experticeApiCitiesList.cities?.includes(center.city_en_slug),
) ||
experticeApiCitiesList.cities?.includes('*');
} catch (error) {
console.error(error);
}
Expand Down Expand Up @@ -112,15 +123,16 @@ export const getProfileServerSideProps = withServerUtils(async (context: GetServ
employee_id: providerData.value.employee_id,
};

const parallelRequests = [await getSpecialitiesData({ provider_id: providerData.value.id })];

const [specialitiesData] = await Promise.allSettled(parallelRequests);
if (shouldUseExpertice) {
const parallelRequests = [await getSpecialitiesData({ provider_id: providerData.value.id })];
const [specialitiesData] = await Promise.allSettled(parallelRequests);

if (specialitiesData.status === 'fulfilled') {
profileData.provider = {
...profileData.provider,
expertises: Object.values(specialitiesData.value),
};
if (specialitiesData.status === 'fulfilled') {
profileData.provider = {
...profileData.provider,
expertises: Object.values(specialitiesData.value),
};
}
}

if (shouldUseUser) {
Expand Down