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

Tampereen Seutuselvitysraportti osa 3: vuosittaisten arvojen CSV #6335

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import styled from 'styled-components'
import { useTranslation } from 'employee-frontend/state/i18n'
import {
RegionalSurveyReportAgeStatisticsResult,
RegionalSurveyReportResult
RegionalSurveyReportResult,
RegionalSurveyReportYearlyStatisticsResult
} from 'lib-common/generated/api-types/reports'
import LocalDate from 'lib-common/local-date'
import { constantQuery, useQueryResult } from 'lib-common/query'
Expand All @@ -33,7 +34,8 @@ import ReportDownload from './ReportDownload'
import { FilterLabel, FilterRow } from './common'
import {
tampereRegionalSurveyAgeReport,
tampereRegionalSurveyMonthlyReport
tampereRegionalSurveyMonthlyReport,
tampereRegionalSurveyYearlyReport
} from './queries'

interface ReportQueryParams {
Expand All @@ -43,11 +45,28 @@ interface ReportQueryParams {
interface ReportSelection {
monthlyStatistics: boolean
ageStatistics: boolean
yearlyStatistics: boolean
}

const emptyReportSelection = {
monthlyStatistics: false,
ageStatistics: false
ageStatistics: false,
yearlyStatistics: false
}

const emptyMonthlyValue: RegionalSurveyReportResult = {
monthlyCounts: [],
year: 0
}

const emptyAgeValue: RegionalSurveyReportAgeStatisticsResult = {
ageStatistics: [],
year: 0
}

const emptyYearlyValue: RegionalSurveyReportYearlyStatisticsResult = {
yearlyStatistics: [],
year: 0
}

export default React.memo(function TampereRegionalSurveyReport() {
Expand All @@ -69,16 +88,6 @@ export default React.memo(function TampereRegionalSurveyReport() {
null
)

const emptyMonthlyValue: RegionalSurveyReportResult = {
monthlyCounts: [],
year: 0
}

const emptyAgeValue: RegionalSurveyReportAgeStatisticsResult = {
ageStatistics: [],
year: 0
}

const [reportSelection, setReportSelection] =
useState<ReportSelection>(emptyReportSelection)

Expand All @@ -94,6 +103,12 @@ export default React.memo(function TampereRegionalSurveyReport() {
: constantQuery(emptyAgeValue)
)

const yearlyStatisticsResult = useQueryResult(
activeParams && reportSelection.yearlyStatistics
? tampereRegionalSurveyYearlyReport(activeParams)
: constantQuery(emptyYearlyValue)
)

const fetchMonthlyResults = useCallback(() => {
if (selectedYear) {
setReportSelection({ ...reportSelection, monthlyStatistics: true })
Expand All @@ -108,6 +123,13 @@ export default React.memo(function TampereRegionalSurveyReport() {
}
}, [selectedYear, reportSelection])

const fetchYearlyResults = useCallback(() => {
if (selectedYear) {
setReportSelection({ ...reportSelection, yearlyStatistics: true })
setActiveParams({ year: selectedYear })
}
}, [selectedYear, reportSelection])

const changeYear = useCallback(
(newYear: number | null) => {
if (selectedYear !== newYear) {
Expand Down Expand Up @@ -279,6 +301,118 @@ export default React.memo(function TampereRegionalSurveyReport() {
) : null
})}
</ReportRow>
<ReportRow spacing="L" alignItems="center" fullWidth>
<ReportLabel>{t.yearlyStatisticsReport}</ReportLabel>
<Button
primary
disabled={!selectedYear}
text={i18n.common.search}
onClick={fetchYearlyResults}
data-qa="fetch-yearly-button"
/>
{renderResult(yearlyStatisticsResult, (result) => {
return result.yearlyStatistics.length > 0 &&
result.year === selectedYear ? (
<ReportDownload
data={result.yearlyStatistics}
headers={[
{
label: t.yearlyStatisticsColumns.voucherTotalCount,
key: 'voucherTotalCount'
},
{
label: t.yearlyStatisticsColumns.voucherAssistanceCount,
key: 'voucherAssistanceCount'
},
{
label: t.yearlyStatisticsColumns.voucher5YearOldCount,
key: 'voucher5YearOldCount'
},
{
label: t.yearlyStatisticsColumns.purchased5YearlOldCount,
key: 'purchased5YearOldCount'
},
{
label: t.yearlyStatisticsColumns.municipal5YearOldCount,
key: 'municipal5YearOldCount'
},
{
label: t.yearlyStatisticsColumns.familyCare5YearOldCount,
key: 'familyCare5YearOldCount'
},
{
label: t.yearlyStatisticsColumns.club5YearOldCount,
key: 'club5YearOldCount'
},
{
label:
t.yearlyStatisticsColumns.preschoolDaycareUnitCareCount,
key: 'preschoolDaycareUnitCareCount'
},
{
label:
t.yearlyStatisticsColumns
.preschoolDaycareSchoolCareCount,
key: 'preschoolDaycareSchoolCareCount'
},
{
label:
t.yearlyStatisticsColumns
.preschoolDaycareFamilyCareCount,
key: 'preschoolDaycareFamilyCareCount'
},
{
label:
t.yearlyStatisticsColumns
.preschoolDaycareSchoolShiftCareCount,
key: 'preschoolDaycareSchoolShiftCareCount'
},
{
label:
t.yearlyStatisticsColumns
.preschoolDaycareUnitShiftCareCount,
key: 'preschoolDaycareUnitShiftCareCount'
},
{
label:
t.yearlyStatisticsColumns.voucherGeneralAssistanceCount,
key: 'voucherGeneralAssistanceCount'
},
{
label:
t.yearlyStatisticsColumns.voucherSpecialAssistanceCount,
key: 'voucherSpecialAssistanceCount'
},
{
label:
t.yearlyStatisticsColumns
.voucherEnhancedAssistanceCount,
key: 'voucherEnhancedAssistanceCount'
},
{
label:
t.yearlyStatisticsColumns
.municipalGeneralAssistanceCount,
key: 'municipalGeneralAssistanceCount'
},
{
label:
t.yearlyStatisticsColumns
.municipalSpecialAssistanceCount,
key: 'municipalSpecialAssistanceCount'
},
{
label:
t.yearlyStatisticsColumns
.municipalEnhancedAssistanceCount,
key: 'municipalEnhancedAssistanceCount'
}
]}
filename={`${t.reportLabel} ${selectedYear} - ${t.yearlyStatisticsReport}.csv`}
/>
) : null
})}
</ReportRow>
</FixedSpaceColumn>
</ContentArea>
</Container>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/employee-frontend/components/reports/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
getStartingPlacementsReport,
getTampereRegionalSurveyAgeStatistics,
getTampereRegionalSurveyMonthlyStatistics,
getTampereRegionalSurveyYearlyStatistics,
getTitaniaErrorsReport,
getUnitsReport,
getVardaChildErrorsReport,
Expand Down Expand Up @@ -152,3 +153,7 @@ export const tampereRegionalSurveyMonthlyReport = q.query(
export const tampereRegionalSurveyAgeReport = q.query(
getTampereRegionalSurveyAgeStatistics
)

export const tampereRegionalSurveyYearlyReport = q.query(
getTampereRegionalSurveyYearlyStatistics
)
21 changes: 21 additions & 0 deletions frontend/src/employee-frontend/generated/api-clients/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { ProviderType } from 'lib-common/generated/api-types/daycare'
import { RawReportRow } from 'lib-common/generated/api-types/reports'
import { RegionalSurveyReportAgeStatisticsResult } from 'lib-common/generated/api-types/reports'
import { RegionalSurveyReportResult } from 'lib-common/generated/api-types/reports'
import { RegionalSurveyReportYearlyStatisticsResult } from 'lib-common/generated/api-types/reports'
import { Report } from 'lib-common/generated/api-types/reports'
import { ServiceNeedReportRow } from 'lib-common/generated/api-types/reports'
import { ServiceVoucherReport } from 'lib-common/generated/api-types/reports'
Expand Down Expand Up @@ -1101,6 +1102,26 @@ export async function getTampereRegionalSurveyMonthlyStatistics(
}


/**
* Generated from fi.espoo.evaka.reports.TampereRegionalSurvey.getTampereRegionalSurveyYearlyStatistics
*/
export async function getTampereRegionalSurveyYearlyStatistics(
request: {
year: number
}
): Promise<RegionalSurveyReportYearlyStatisticsResult> {
const params = createUrlSearchParams(
['year', request.year.toString()]
)
const { data: json } = await client.request<JsonOf<RegionalSurveyReportYearlyStatisticsResult>>({
url: uri`/employee/reports/tampere-regional-survey/yearly-statistics`.toString(),
method: 'GET',
params
})
return json
}


/**
* Generated from fi.espoo.evaka.reports.TitaniaErrorReport.clearTitaniaErrors
*/
Expand Down
32 changes: 32 additions & 0 deletions frontend/src/lib-common/generated/api-types/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,14 @@ export interface RegionalSurveyReportResult {
year: number
}

/**
* Generated from fi.espoo.evaka.reports.TampereRegionalSurvey.RegionalSurveyReportYearlyStatisticsResult
*/
export interface RegionalSurveyReportYearlyStatisticsResult {
year: number
yearlyStatistics: YearlyStatisticsResult[]
}

/**
* Generated from fi.espoo.evaka.reports.Report
*/
Expand Down Expand Up @@ -1153,6 +1161,30 @@ export type VoucherReportRowType =
| 'CORRECTION'
| 'ORIGINAL'

/**
* Generated from fi.espoo.evaka.reports.TampereRegionalSurvey.YearlyStatisticsResult
*/
export interface YearlyStatisticsResult {
club5YearOldCount: number
familyCare5YearOldCount: number
municipal5YearOldCount: number
municipalEnhancedAssistanceCount: number
municipalGeneralAssistanceCount: number
municipalSpecialAssistanceCount: number
preschoolDaycareFamilyCareCount: number
preschoolDaycareSchoolCareCount: number
preschoolDaycareSchoolShiftCareCount: number
preschoolDaycareUnitCareCount: number
preschoolDaycareUnitShiftCareCount: number
purchased5YearOldCount: number
voucher5YearOldCount: number
voucherAssistanceCount: number
voucherEnhancedAssistanceCount: number
voucherGeneralAssistanceCount: number
voucherSpecialAssistanceCount: number
voucherTotalCount: number
}


export function deserializeJsonAssistanceNeedDecisionsReportRow(json: JsonOf<AssistanceNeedDecisionsReportRow>): AssistanceNeedDecisionsReportRow {
return {
Expand Down
32 changes: 32 additions & 0 deletions frontend/src/lib-customizations/defaults/employee/i18n/fi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4327,6 +4327,7 @@ export const fi = {
'Raportti kerää kunnan vuosittaiseen seutuselvitykseen tarvittavat tiedot ladattaviksi CSV-tiedostoiksi',
monthlyReport: 'Seutuselvityksen kuukausittaiset määrät',
ageStatisticsReport: 'Seutuselvityksen ikäjakaumat',
yearlyStatisticsReport: 'Seutuselvityksen vuosittaiset määrät',
reportLabel: 'Seutuselvitys',
monthlyColumns: {
month: 'Kuukausi',
Expand Down Expand Up @@ -4359,6 +4360,37 @@ export const fi = {
'Alle 3v perhepäivähoidon hoitopäivät',
effectiveFamilyDaycareDaysOver3Count:
'3v ja yli perhepäivähoidon hoitopäivät'
},
yearlyStatisticsColumns: {
voucherTotalCount: 'Palvelusetelien määrä',
voucherAssistanceCount: 'Tuen lasten määrä palveluseteliyksiköissä',
voucher5YearOldCount: '5-vuotiaat palveluseteliyksiköissä',
purchased5YearlOldCount: '5-vuotiaat ostopalveluyksiköissä',
municipal5YearOldCount: '5-vuotiaat kunnallisissa yksiköissä',
familyCare5YearOldCount: '5-vuotiaat perhepäivähoidossa',
club5YearOldCount: '5-vuotiaat kerhossa',
preschoolDaycareUnitCareCount:
'Täydentävän varhaiskasvatuksen lapset vaka-yksiköissä',
preschoolDaycareSchoolCareCount:
'Täydentävän varhaiskasvatuksen lapset kouluissa',
preschoolDaycareFamilyCareCount:
'Täydentävän varhaiskasvatuksen lapset perhepäivähoidossa',
preschoolDaycareUnitShiftCareCount:
'Täydentävän varhaiskasvatuksen vuorohoidon lapset vaka-yksiköissä',
preschoolDaycareSchoolShiftCareCount:
'Täydentävän varhaiskasvatuksen vuorohoidon lapset kouluissa',
voucherGeneralAssistanceCount:
'Yleisen tuen lapsimäärä (palveluseteli)',
voucherSpecialAssistanceCount:
'Erityisen tuen lapsimäärä (palveluseteli)',
voucherEnhancedAssistanceCount:
'Tehostetun tuen lapsimäärä (palveluseteli)',
municipalGeneralAssistanceCount:
'Yleisen tuen lapsimäärä (kunnallinen)',
municipalSpecialAssistanceCount:
'Erityisen tuen lapsimäärä (kunnallinen)',
municipalEnhancedAssistanceCount:
'Tehostetun tuen lapsimäärä (kunnallinen)'
}
}
},
Expand Down
Loading
Loading