Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules
yarn.lock
/.vscode
/test/karma.browserstack.conf.js
.claude/settings.local.json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Definitely fine in this gitignore, but I also added it to my global gitignore so I don't run into it too often

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "traitify-widgets",
"version": "3.9.7",
"version": "3.9.7-beta-1.0",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's bump to 3.9.8 and release it after it's all merged.

Also usually we want to bump to like 3.9.8-beta.x since 3.9.7 is already released (basically starting the alpha/beta on the next version instead of current).

Also, when it's a alpha or beta make sure to tag it when you publish so it doesn't make it to the @latest tag unless you want it to. You can still install it with npm i -S traitify-widgets@beta

"description": "Traitiy Widgets",
"repository": {
"type": "git",
Expand Down
40 changes: 25 additions & 15 deletions src/lib/recoil/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,34 @@ const baseRecommendationQuery = selector({
const GraphQL = get(graphqlState);
const http = get(httpState);
const options = get(optionsState);
const variables = {
benchmarkID,
localeKey: get(localeState),
packageID,
profileID
const localeKey = get(localeState);
const {path} = GraphQL.xavier;
const hasExpirationFlag = Object.hasOwn(options, "applyAssessmentExpiration");
const initialExpirationFlag = hasExpirationFlag ? options.applyAssessmentExpiration : null;

const fetchRecommendation = async(applyAssessmentExpiration) => {
const variables = {benchmarkID, localeKey, packageID, profileID};
if(applyAssessmentExpiration !== null) {
variables.applyAssessmentExpiration = applyAssessmentExpiration;
}
const params = {query: GraphQL.xavier.recommendation, variables};
const recResponse = await http.post({path, params}).catch((e) => ({errors: [e.message]}));
return {order: orderFromRecommendation(recResponse), response: recResponse};
};
if(Object.hasOwn(options, "applyAssessmentExpiration")) {
variables.applyAssessmentExpiration = options.applyAssessmentExpiration;
}

const params = {
query: GraphQL.xavier.recommendation,
variables
};
let {order, response} = await fetchRecommendation(initialExpirationFlag);

if(options.retryRecommendationOnIncompletePersonality && hasExpirationFlag && !order.errors) {
const personality = response.data?.recommendation?.prerequisites?.personality;
if(personality?.surveyId && !personality.assessmentId) {
const retry = await fetchRecommendation(!initialExpirationFlag);
const retryPersonality = retry.response.data?.recommendation?.prerequisites?.personality;
if(retryPersonality?.assessmentId) {
({order, response} = retry);
}
}
}

const {path} = GraphQL.xavier;
const response = await http.post({path, params}).catch((e) => ({errors: [e.message]}));
const order = orderFromRecommendation(response);
order.cacheKey = cacheKey;
order.origin = {benchmarkID, packageID, profileID};

Expand Down