mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[Shared] Extract type GraduationStatistics
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { indexOf, orderBy } from 'lodash'
|
||||
import moment from 'moment'
|
||||
|
||||
import { Name } from '../../shared/types'
|
||||
import { GraduationStatistics, Name } from '../../shared/types'
|
||||
import { mapToProviders } from '../../shared/util'
|
||||
import { DegreeProgrammeType, ExtentCode, Phase, SemesterEnrollment, StudyTrack } from '../../types'
|
||||
import { getDegreeProgrammeType, getMinimumCreditsOfProgramme, sortByProgrammeCode } from '../../util'
|
||||
@@ -74,7 +74,7 @@ export type GraduationTimes = {
|
||||
y: number
|
||||
amount: number
|
||||
name: string | number
|
||||
statistics: { onTime: number; yearOver: number; wayOver: number }
|
||||
statistics: GraduationStatistics
|
||||
times: number[]
|
||||
}>
|
||||
goal: number
|
||||
|
||||
+3
-7
@@ -7,7 +7,7 @@ import exporting from 'highcharts/modules/exporting'
|
||||
import ReactHighcharts from 'react-highcharts'
|
||||
|
||||
import { useLanguage } from '@/components/LanguagePicker/useLanguage'
|
||||
import { GraduationStats, Name, NameWithCode } from '@/shared/types'
|
||||
import { GraduationStatistics, GraduationStats, Name, NameWithCode } from '@/shared/types'
|
||||
|
||||
exporting(ReactHighcharts.Highcharts)
|
||||
exportData(ReactHighcharts.Highcharts)
|
||||
@@ -113,7 +113,7 @@ export const MedianBarChart = ({
|
||||
code: string,
|
||||
amount: number,
|
||||
median: number,
|
||||
statistics: { onTime: number; yearOver: number; wayOver: number },
|
||||
statistics: GraduationStatistics,
|
||||
realGoal: number | undefined
|
||||
) => {
|
||||
const sortingText =
|
||||
@@ -150,11 +150,7 @@ export const MedianBarChart = ({
|
||||
const point = this.point as Highcharts.Point & {
|
||||
code?: string
|
||||
amount?: number
|
||||
statistics?: {
|
||||
onTime: number
|
||||
yearOver: number
|
||||
wayOver: number
|
||||
}
|
||||
statistics?: GraduationStatistics
|
||||
realGoal?: number
|
||||
}
|
||||
return getTooltipText(
|
||||
|
||||
@@ -6,13 +6,12 @@ import exporting from 'highcharts/modules/exporting'
|
||||
import ReactHighcharts from 'react-highcharts'
|
||||
|
||||
import { Section } from '@/components/material/Section'
|
||||
import { GraduationStatistics } from '@/shared/types'
|
||||
|
||||
exporting(ReactHighcharts.Highcharts)
|
||||
exportData(ReactHighcharts.Highcharts)
|
||||
accessibility(ReactHighcharts.Highcharts)
|
||||
|
||||
type Statistics = { onTime: number; yearOver: number; wayOver: number }
|
||||
|
||||
export const MedianTimeBarChart = ({
|
||||
byStartYear,
|
||||
data,
|
||||
@@ -24,7 +23,7 @@ export const MedianTimeBarChart = ({
|
||||
amount: number
|
||||
classSize: number
|
||||
name: string
|
||||
statistics: Statistics
|
||||
statistics: GraduationStatistics
|
||||
times: number[]
|
||||
y: number
|
||||
}>
|
||||
@@ -56,7 +55,13 @@ export const MedianTimeBarChart = ({
|
||||
return data.length * multiplier + 100
|
||||
}
|
||||
|
||||
const getTooltipText = (amount: number, y: number, year: string, statistics: Statistics, classSize: number) => {
|
||||
const getTooltipText = (
|
||||
amount: number,
|
||||
y: number,
|
||||
year: string,
|
||||
statistics: GraduationStatistics,
|
||||
classSize: number
|
||||
) => {
|
||||
const sortingText =
|
||||
byStartYear && title !== 'Bachelor + master study right'
|
||||
? `<b>From class of ${year}, ${amount}/${classSize} students have graduated</b>`
|
||||
@@ -83,7 +88,7 @@ export const MedianTimeBarChart = ({
|
||||
const point = this.point as Highcharts.Point & {
|
||||
amount: number
|
||||
name: string
|
||||
statistics: Statistics
|
||||
statistics: GraduationStatistics
|
||||
classSize: number
|
||||
}
|
||||
return getTooltipText(point.amount, this.y!, point.name, point.statistics, point.classSize)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { RTKApi } from '@/apiConnection'
|
||||
import { useLanguage } from '@/components/LanguagePicker/useLanguage'
|
||||
import { Graduated, SpecialGroups, StudyTrackStats } from '@/shared/types'
|
||||
import { getCombinedProgrammeName } from '@/util/combinedProgramme'
|
||||
import { useGetProgrammesQuery } from './populations'
|
||||
|
||||
@@ -22,7 +23,10 @@ const studyProgrammeApi = RTKApi.injectEndpoints({
|
||||
query: ({ id, yearType, specialGroups, combinedProgramme }) =>
|
||||
`/v2/studyprogrammes/${id}/graduationstats?year_type=${yearType}&special_groups=${specialGroups}&combined_programme=${combinedProgramme}`,
|
||||
}),
|
||||
getStudyTrackStats: builder.query({
|
||||
getStudyTrackStats: builder.query<
|
||||
StudyTrackStats,
|
||||
{ id: string; graduated: Graduated; specialGroups: SpecialGroups; combinedProgramme: string }
|
||||
>({
|
||||
query: ({ id, graduated, specialGroups, combinedProgramme }) =>
|
||||
`/v2/studyprogrammes/${id}/studytrackstats?graduated=${graduated}&special_groups=${specialGroups}&combined_programme=${combinedProgramme}`,
|
||||
}),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { GraduationStatistics } from './graduations'
|
||||
|
||||
export type Graduated = 'GRADUATED_INCLUDED' | 'GRADUATED_EXCLUDED'
|
||||
export type ProgrammeFilter = 'NEW_STUDY_PROGRAMMES' | 'ALL_PROGRAMMES'
|
||||
export type SpecialGroups = 'SPECIAL_INCLUDED' | 'SPECIAL_EXCLUDED'
|
||||
@@ -8,11 +10,7 @@ export type GraduationStats = {
|
||||
amount: number
|
||||
median: number
|
||||
name: number
|
||||
statistics: {
|
||||
onTime: number
|
||||
yearOver: number
|
||||
wayOver: number
|
||||
}
|
||||
statistics: GraduationStatistics
|
||||
times: number[]
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export type GraduationStatistics = {
|
||||
onTime: number
|
||||
yearOver: number
|
||||
wayOver: number
|
||||
}
|
||||
@@ -8,6 +8,7 @@ export type {
|
||||
StatsType,
|
||||
YearType,
|
||||
} from './faculty'
|
||||
export type { GraduationStatistics } from './graduations'
|
||||
export type { Name, NameWithCode } from './name'
|
||||
export type { Release } from './release'
|
||||
export type { Role } from './role'
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { GraduationStatistics } from './graduations'
|
||||
import { Name } from './name'
|
||||
|
||||
export type MedianEntry = {
|
||||
amount: number
|
||||
classSize: number
|
||||
name: string
|
||||
statistics: {
|
||||
onTime: number
|
||||
yearOver: number
|
||||
wayOver: number
|
||||
}
|
||||
statistics: GraduationStatistics
|
||||
times: number[]
|
||||
y: number
|
||||
}
|
||||
@@ -26,9 +23,9 @@ export type Goals = {
|
||||
}
|
||||
|
||||
export type GraduationTimes = {
|
||||
goals: Goals
|
||||
} & {
|
||||
[programmeOrStudyTrack: string]: ProgrammeOrStudyTrackGraduationStats
|
||||
} & {
|
||||
goals: Goals
|
||||
}
|
||||
|
||||
export type StudyTrackStats = {
|
||||
|
||||
Reference in New Issue
Block a user