refactor: add dynamic semester boostings

This commit is contained in:
Rainer Killinger
2022-02-02 13:31:33 +01:00
parent 9c5581af2c
commit 18c628a002
5 changed files with 58 additions and 90 deletions

View File

@@ -2,40 +2,11 @@
// tslint:disable:no-magic-numbers
import {SCConfigFile} from '@openstapps/core';
import {RecursivePartial} from '@openstapps/logger/lib/common';
import moment from 'moment';
import {inRangeInclusive} from './default';
const ssRange = [4, 9];
const wsRange = [10, 3];
const month = moment()
.month();
const year = moment()
.year();
const wsYearOffset = (month < wsRange[0] ? -1 : 0);
const wsAcronym = `WS ${year + wsYearOffset}/${(year + 1 + wsYearOffset)
.toString()
.slice(-2)}`;
const ssAcronym = `SS ${year + (month <= wsRange[1] ? -1 : 0)}`;
/**
* This is the default configuration for the technical university of Berlin
*/
const config: RecursivePartial<SCConfigFile> = {
internal: {
boostings: {
default: [
{
factor: 1,
fields: {
'academicTerms.acronym': {
[ssAcronym]: inRangeInclusive(month, ssRange) ? 1.1 : 1.05,
[wsAcronym]: inRangeInclusive(month, wsRange) ? 1.1 : 1.05,
},
},
},
],
},
},
};
export default config;

View File

@@ -579,6 +579,18 @@ const config: RecursivePartial<SCConfigFile> = {
},
},
app: {
features: {
extern: {
hisometry: {
authProvider: 'default',
url: 'https://his-self-service.rz.uni-frankfurt.de',
},
paia: {
authProvider: 'paia',
url: 'https://hds.hebis.de:8443/core',
},
},
},
aboutPages: {
'about': {
title: 'Über das StApps Projekt',

View File

@@ -2,41 +2,11 @@
// tslint:disable:no-magic-numbers
import {SCConfigFile} from '@openstapps/core';
import {RecursivePartial} from '@openstapps/logger/lib/common';
import moment from 'moment';
import {inRangeInclusive} from './default';
const ssRange = [4, 9];
const wsRange = [10, 3];
const month = moment()
.month();
const year = moment()
.year();
const wsYearOffset = (month < wsRange[0] ? -1 : 0);
const wsAcronym = `WS ${(year + wsYearOffset).toString()
.slice(-2)}/${(year + 1 + wsYearOffset).toString()
.slice(-2)}`;
const ssAcronym = `SS ${(year + (month <= wsRange[1] ? -1 : 0)).toString()
.slice(-2)}`;
/**
* This is the default configuration for the university of Kassel
*/
const config: RecursivePartial<SCConfigFile> = {
internal: {
boostings: {
default: [
{
factor: 1,
fields: {
'academicTerms.acronym': {
[ssAcronym]: inRangeInclusive(month, ssRange) ? 1.1 : 1.05,
[wsAcronym]: inRangeInclusive(month, wsRange) ? 1.1 : 1.05,
},
},
},
],
},
},
};
export default config;

View File

@@ -2,41 +2,12 @@
// tslint:disable:no-magic-numbers
import {SCConfigFile} from '@openstapps/core';
import {RecursivePartial} from '@openstapps/logger/lib/common';
import moment from 'moment';
import {inRangeInclusive} from './default';
const ssRange = [4, 9];
const wsRange = [10, 3];
const month = moment()
.month();
const year = moment()
.year();
const wsYearOffset = (month < wsRange[0] ? -1 : 0);
const wsAcronym = `WiSe ${(year + wsYearOffset).toString()
.slice(-2)}/${(year + 1 + wsYearOffset).toString()
.slice(-2)}`;
const ssAcronym = `SoSe ${(year + (month <= wsRange[1] ? -1 : 0)).toString()
.slice(-2)}`;
/**
* This is the default configuration for the university of Kassel
*/
const config: RecursivePartial<SCConfigFile> = {
internal: {
boostings: {
default: [
{
factor: 1,
fields: {
'academicTerms.acronym': {
[ssAcronym]: inRangeInclusive(month, ssRange) ? 1.1 : 1.05,
[wsAcronym]: inRangeInclusive(month, wsRange) ? 1.1 : 1.05,
},
},
},
],
},
},
};
export default config;

View File

@@ -22,6 +22,22 @@ export function inRangeInclusive(num: number, range: number[]): boolean {
return num >= range[0] && num <= range[1];
}
const sommerRange = [4, 9];
const winterRange = [10, 3];
const month = new Date().getMonth();
const year = new Date().getFullYear();
const winterYearOffset = (month < winterRange[0] ? -1 : 0);
const sommerYear = year + (month <= winterRange[1] ? -1 : 0);
const winterYear = `${year + winterYearOffset}/${(year + 1 + winterYearOffset)
.toString()
.slice(-2)}`;
const wsAcronymShort = `WS ${winterYear}`;
const ssAcronymShort = `SS ${sommerYear}`;
const wsAcronymLong = `WiSe ${winterYear}`;
const ssAcronymLong = `SoSe ${sommerYear}`;
const userGroupSetting: SCUserGroupSetting = {
categories: ['profile'],
defaultValue: 'students',
@@ -430,6 +446,19 @@ const config: Partial<SCConfigFile> = {
},
},
},
{
icon: 'search',
route: '/hebis-search',
title: 'library catalog',
translations: {
de: {
title: 'Bibliothekskatalog',
},
en: {
title: 'library catalog',
},
},
},
{
icon: 'folder',
route: '/catalog',
@@ -471,6 +500,19 @@ const config: Partial<SCConfigFile> = {
icon: 'person',
id: 'personal',
items: [
{
icon: 'library',
route: '/library-account',
title: 'library account',
translations: {
de: {
title: 'Bibliothekskonto',
},
en: {
title: 'library account',
},
},
},
{
icon: 'star',
route: '/favorites',
@@ -713,8 +755,10 @@ const config: Partial<SCConfigFile> = {
factor: 1,
fields: {
'academicTerms.acronym': {
'SoSe 2022': 1.05,
'WiSe 2021/2022': 1.1,
[ssAcronymShort]: inRangeInclusive(month, sommerRange) ? 1.1 : 1.05,
[wsAcronymShort]: inRangeInclusive(month, winterRange) ? 1.1 : 1.05,
[ssAcronymLong]: inRangeInclusive(month, sommerRange) ? 1.1 : 1.05,
[wsAcronymLong]: inRangeInclusive(month, winterRange) ? 1.1 : 1.05,
},
},
type: SCThingType.AcademicEvent,