Skip to content

Commit

Permalink
Prettified Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavriil-Tzortzakis authored and actions-user committed Oct 31, 2024
1 parent ffc5aa1 commit 1751b84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
3 changes: 0 additions & 3 deletions shared/locales/en/website-responses.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@
"title": "Follow-up Survey",
"description": "Filled out every 6 months after recipient left the program"
}



}
10 changes: 4 additions & 6 deletions shared/src/utils/stats/SurveyStatsCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class SurveyStatsCalculator {
private readonly _surveyStats: _.Collection<Survey>;
private readonly _data: SurveyStats[];

private constructor(surveyStats: _.Collection<Survey>,data:SurveyStats[]) {
private constructor(surveyStats: _.Collection<Survey>, data: SurveyStats[]) {
this._surveyStats = surveyStats;
this._data = data;
}
Expand All @@ -42,21 +42,19 @@ export class SurveyStatsCalculator {
)
)
.flatMap((snapshot) => snapshot.docs)
.map(survey=> survey.data() )
.map((survey) => survey.data());
const typeCounts: { [type: string]: number } = {};
surveysData.forEach(item => {
surveysData.forEach((item) => {
typeCounts[item.questionnaire] = (typeCounts[item.questionnaire] || 0) + 1;
});

const data = Object.entries(typeCounts).map(([type, total]) => ({ type, total }));

// @ts-ignore
return new SurveyStatsCalculator(_(surveysData),data);
return new SurveyStatsCalculator(_(surveysData), data);
}

get data(): SurveyStats[] {


return this._data;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DefaultPageProps } from '@/app/[lang]/[region]';
import { firestoreAdmin } from '@/firebase-admin';
import { SurveyQuestionnaire } from '@socialincome/shared/src/types/survey';
import { Translator } from '@socialincome/shared/src/utils/i18n';
import { SurveyStatsCalculator } from '@socialincome/shared/src/utils/stats/SurveyStatsCalculator';
import { BaseContainer, Card, CardTitle, Typography } from '@socialincome/ui';
import { Translator } from '@socialincome/shared/src/utils/i18n';
import { DefaultPageProps } from '@/app/[lang]/[region]';
import { SurveyQuestionnaire } from '@socialincome/shared/src/types/survey';

export const revalidate = 3600; // update once an hour
export default async function Page({ params: { lang } }: DefaultPageProps) {
Expand Down

0 comments on commit 1751b84

Please sign in to comment.