-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: integrate FLSS with ERL email #5743
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
import fetchGraphQL from '../fetchGraphQL.js'; | ||
import { warn, error } from '../log.js'; | ||
|
||
export const QUERY_TYPE = { | ||
DEFAULT: 'default', | ||
FLSS: 'flss', | ||
RECOMMENDATIONS: 'recommendations' | ||
}; | ||
|
||
// Number of loans to fetch | ||
const loanCount = 4; | ||
|
||
|
@@ -60,8 +66,27 @@ async function fetchLoansFromGraphQL(request, resultPath) { | |
} | ||
|
||
// Get per-user recommended loans from the ML service | ||
async function fetchRecommendationsByLoginId(id, flss = false) { | ||
if (flss) { | ||
async function fetchRecommendationsByLoginId(id, queryType = QUERY_TYPE.DEFAULT) { | ||
if (queryType === QUERY_TYPE.RECOMMENDATIONS) { | ||
return fetchLoansFromGraphQL( | ||
{ | ||
query: `query($userId: Int, $limit: Int) { | ||
loanRecommendations( | ||
userId: $userId, | ||
limit: ${loanCount}, | ||
origin: "email:live-loans" | ||
) { | ||
${loanValues} | ||
} | ||
}`, | ||
variables: { | ||
userId: Number(id), | ||
limit: loanCount | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michelleinez @dyersituations There might be an issue here with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it defined up above on line 11? It also looks like it was originally used in this same exact way down below in the FLSS fetch query... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it appears to be! But you,ll want to confirm the actual query operation and combination of variables and that the failure isn't somewhere in the code setup... |
||
} | ||
}, | ||
'data.loanRecommendations.values' | ||
); | ||
} if (queryType === QUERY_TYPE.FLSS) { | ||
return fetchLoansFromGraphQL( | ||
{ | ||
query: `query($userId: Int) { | ||
|
@@ -495,9 +520,9 @@ const shouldUseFLSS = async filterString => { | |
}; | ||
|
||
// Export a function that will fetch loans by live-loan type and id | ||
export default async function fetchLoansByType(type, id, flss = false) { | ||
export default async function fetchLoansByType(type, id, queryType = QUERY_TYPE.DEFAULT) { | ||
if (type === 'user') { | ||
return fetchRecommendationsByLoginId(id, flss); | ||
return fetchRecommendationsByLoginId(id, queryType); | ||
} if (type === 'loan') { | ||
return fetchRecommendationsByLoanId(id); | ||
} if (type === 'filter') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this locally and encountered a server error. Is the new endpoint live and ready?
URL: https://kiva-ui.local/live-loan/recommendations/u/2230848/img2/1
Error on console locally:
Error serving image, Error: No loans returned
Working alternative (old FLSS): https://kiva-ui.local/live-loan/flss/u/2230848/img2/1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was about to approve then saw this :)
I can make a basic query with that user id and it works ok in dev and prod...