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

feat: lender stats data import updated #5467

Merged
merged 3 commits into from
Aug 28, 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
14 changes: 7 additions & 7 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
Expand Up @@ -49,7 +49,7 @@
"@godaddy/terminus": "^4.11.0",
"@graphql-tools/load": "^7.7.0",
"@graphql-tools/url-loader": "^7.17.18",
"@kiva/kv-components": "^3.94.0",
"@kiva/kv-components": "^3.96.0",
"@kiva/kv-shop": "^1.12.8",
"@kiva/kv-tokens": "^2.11.1",
"@mdi/js": "^7",
Expand Down
6 changes: 5 additions & 1 deletion src/components/LenderProfile/LenderMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export default {
type: Object,
required: true,
},
lenderStats: {
type: Object,
required: true,
},
},
data() {
return {
Expand All @@ -125,7 +129,7 @@ export default {
: 'Lending Activity by Country';
},
countriesData() {
return (this.lenderInfo?.statsPerCountry?.values ?? []).map(stat => ({
return (this.lenderStats?.statsPerCountry?.values ?? []).map(stat => ({
label: stat.country?.name ?? '',
value: stat.loanCount ?? '',
lat: stat.country?.geocode?.latitude ?? 0,
Expand Down
29 changes: 28 additions & 1 deletion src/components/LenderProfile/LenderProfileWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,21 @@
/>

<lender-stats
:lender-info="lenderInfo"
:public-id="publicId"
:lender-stats="lenderStats"
@get-lender-stats="fetchLenderStats"
/>

<lender-map
:lender-info="lenderInfo"
:lender-stats="lenderStats"
/>
</div>
</template>

<script>
import lenderStatsQuery from '@/graphql/query/lenderStats.graphql';
import logReadQueryError from '@/util/logReadQueryError';
import LenderSummary from '@/components/LenderProfile/LenderSummary';
import LenderLoansList from '@/components/LenderProfile/LenderLoansList';
import LenderStats from '@/components/LenderProfile/LenderStats';
Expand All @@ -53,6 +58,7 @@ import LenderMap from '@/components/LenderProfile/LenderMap';

export default {
name: 'LenderProfileWrapper',
inject: ['apollo', 'cookieStore'],
props: {
publicId: {
type: String,
Expand All @@ -72,6 +78,11 @@ export default {
default: () => ([]),
},
},
data() {
return {
lenderStats: {},
};
},
components: {
LenderSummary,
LenderLoansList,
Expand All @@ -82,5 +93,21 @@ export default {
LenderDedicationsList,
LenderMap,
},
methods: {
async fetchLenderStats() {
try {
const { data } = await this.apollo.query({
query: lenderStatsQuery,
variables: {
publicId: this.publicId,
},
});

this.lenderStats = data.community?.lender ?? {};
} catch (e) {
logReadQueryError(e, 'LenderStats lenderStatsQuery');
}
},
},
};
</script>
23 changes: 14 additions & 9 deletions src/components/LenderProfile/LenderStats.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<async-lender-section @visible="() => isLoading = false">
<async-lender-section @visible="$emit('get-lender-stats')">
<section class="tw-my-8">
<div v-if="isLoading">
<kv-loading-placeholder
Expand Down Expand Up @@ -35,11 +35,9 @@ import AsyncLenderSection from './AsyncLenderSection';

export default {
name: 'LenderStats',
inject: ['apollo', 'cookieStore'],
props: {
lenderInfo: {
lenderStats: {
type: Object,
default: () => ({}),
required: true,
},
},
Expand All @@ -66,29 +64,36 @@ export default {
},
computed: {
locationStats() {
return this.statsWithPercent((this.lenderInfo?.statsPerCountry?.values ?? []).map(stat => ({
return this.statsWithPercent((this.lenderStats?.statsPerCountry?.values ?? []).map(stat => ({
label: stat.country.name,
value: stat.loanCount,
})));
},
genderStats() {
return this.statsWithPercent((this.lenderInfo?.statsPerGender?.values ?? []).map(stat => ({
return this.statsWithPercent((this.lenderStats?.statsPerGender?.values ?? []).map(stat => ({
label: `${stat.gender.charAt(0).toUpperCase()}${stat.gender.slice(1)}`,
value: stat.loanCount,
})));
},
sectorStats() {
return this.statsWithPercent((this.lenderInfo?.statsPerSector?.values ?? []).map(stat => ({
return this.statsWithPercent((this.lenderStats?.statsPerSector?.values ?? []).map(stat => ({
label: stat.sector.name,
value: stat.loanCount,
})));
},
partnerStats() {
return this.statsWithPercent((this.lenderInfo?.statsPerPartner?.values ?? []).map(stat => ({
return this.statsWithPercent((this.lenderStats?.statsPerPartner?.values ?? []).map(stat => ({
label: stat.partner?.name ?? 'No partner',
value: stat.loanCount,
})));
},
}
},
watch: {
lenderStats() {
if (Object.keys(this.lenderStats).length !== 0) {
this.isLoading = false;
}
},
},
};
</script>
42 changes: 0 additions & 42 deletions src/graphql/query/lenderPublicProfile.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,6 @@ query LenderPublicProfile ($publicId: String!) {
otherInfo
url
}
statsPerCountry {
values {
id
loanCount
country {
name
numLoansFundraising
geocode {
latitude
longitude
}
isoCode
}
}
}
statsPerGender {
values {
id
loanCount
gender
}
}
statsPerPartner {
values {
id
loanCount
partner {
id
name
}
}
}
statsPerSector {
values {
id
loanCount
sector {
id
name
}
}
}
}
}
userAchievementProgress(publicId: $publicId) {
Expand Down
49 changes: 49 additions & 0 deletions src/graphql/query/lenderStats.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
query LenderStats ($publicId: String!) {
community {
lender(publicId: $publicId) {
id
statsPerCountry {
values {
id
loanCount
country {
name
numLoansFundraising
geocode {
latitude
longitude
}
isoCode
}
}
}
statsPerGender {
values {
id
loanCount
gender
}
}
statsPerPartner {
values {
id
loanCount
partner {
id
name
}
}
}
statsPerSector {
values {
id
loanCount
sector {
id
name
}
}
}
}
}
}
Loading