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 calculate global metrics #982

Merged
merged 2 commits into from
Oct 30, 2023
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
6 changes: 3 additions & 3 deletions packages/core/src/subgraph/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ const axiosSubgraph = axios.create({
headers: {
'content-type': 'application/json'
},
timeout: 5000
timeout: 10000
});
const axiosCouncilSubgraph = axios.create({
baseURL: config.councilSubgraphUrl,
headers: {
'content-type': 'application/json'
},
timeout: 5000
timeout: 10000
});
const axiosMicrocreditSubgraph = axios.create({
baseURL: config.microcreditSubgraphUrl,
headers: {
'content-type': 'application/json'
},
timeout: 5000
timeout: 10000
});
// TODO: " as any" is a temporary solution to deploy to heroku
// TODO: test this works as expected to reduce timeout
Expand Down
2 changes: 1 addition & 1 deletion services/community-metrics/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const calculate = async (event, context) => {
const today = new Date();

if (today.getHours() <= 1) {
await calcuateCommunitiesMetrics(); // community metrics must be executed before all others
await Promise.all([
calcuateCommunitiesMetrics(),
calcuateGlobalMetrics(),
calcuateCommunitiesDemographics(),
calculateGlobalDemographics()
Expand Down
8 changes: 4 additions & 4 deletions services/community-metrics/src/calcuateGlobalMetrics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Op, col, fn } from 'sequelize';
import { Op, col, fn, literal } from 'sequelize';
import {
config,
database,
Expand Down Expand Up @@ -224,8 +224,8 @@ async function calculateUbiPulse(
attributes: [
[fn('avg', col('ubiRate')), 'avgUbiRate'],
[
fn('avg', col('estimatedDuration')),
'avgEstimatedDuration',
literal('AVG(CASE WHEN "estimatedDuration" < 10e5 THEN "estimatedDuration" ELSE NULL END)'), // ignore outliers
'avgEstimatedDuration'
],
],
where: {
Expand All @@ -246,7 +246,7 @@ async function calculateUbiPulse(
const getAvgComulativeUbi = async (): Promise<string> => {
const communityFoundingRate =
await subgraph.queries.community.communityEntities(
`where: { state_not: 2 }, first: 1000`,
`where: { state_not: 2, maxClaim_lt: 5000 }, first: 1000`,
`maxClaim`
);
const comulativeUbi = communityFoundingRate.reduce(
Expand Down
Loading