feat: boost academic terms dynamically

This commit is contained in:
Wieland Schöbl
2019-09-24 10:44:40 +02:00
committed by Rainer Killinger
parent afd324fc6a
commit 13938ecf21
7 changed files with 164 additions and 37 deletions

41
config/default-b-tu.ts Normal file
View File

@@ -0,0 +1,41 @@
// tslint:disable:no-default-export
// tslint:disable:no-magic-numbers
import {SCConfigFile} from '@openstapps/core';
import {RecursivePartial} from '@openstapps/logger/lib/common';
import * as moment from 'moment';
import {inRangeInclusive} from '../src/common';
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;

42
config/default-fb-fh.ts Normal file
View File

@@ -0,0 +1,42 @@
// tslint:disable:no-default-export
// tslint:disable:no-magic-numbers
import {SCConfigFile} from '@openstapps/core';
import {RecursivePartial} from '@openstapps/logger/lib/common';
import * as moment from 'moment';
import {inRangeInclusive} from '../src/common';
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;

42
config/default-ks-ug.ts Normal file
View File

@@ -0,0 +1,42 @@
// tslint:disable:no-default-export
// tslint:disable:no-magic-numbers
import {SCConfigFile} from '@openstapps/core';
import {RecursivePartial} from '@openstapps/logger/lib/common';
import * as moment from 'moment';
import {inRangeInclusive} from '../src/common';
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

@@ -1,3 +1,5 @@
// tslint:disable:no-default-export
// tslint:disable:no-magic-numbers
import {SCConfigFile, SCThingType} from '@openstapps/core';
/**
@@ -184,10 +186,6 @@ const config: Partial<SCConfigFile> = {
{
factor: 1,
fields: {
'academicTerms.acronym': {
'SS 2018': 1.05,
'WS 2018/19': 1.1,
},
'categories': {
'course': 1.08,
'integrated course': 1.08,
@@ -225,6 +223,25 @@ const config: Partial<SCConfigFile> = {
type: SCThingType.Dish,
},
],
dining: [
{
factor: 1,
fields: {
'categories': {
'cafe': 2,
'canteen': 2,
'restaurant': 2,
'restroom': 1.2,
'student canteen': 2,
},
},
type: SCThingType.Building,
},
{
factor: 2,
type: SCThingType.Dish,
},
],
place: [
{
factor: 2,
@@ -239,28 +256,10 @@ const config: Partial<SCConfigFile> = {
type: SCThingType.Room,
},
],
dining: [
{
factor: 1,
fields: {
'categories': {
'cafe': 2,
'restaurant': 2,
'canteen': 2,
'student canteen': 2,
'restroom': 1.2,
},
},
type: SCThingType.Building,
},
{
factor: 2,
type: SCThingType.Dish,
},
],
},
},
uid: 'b-tu',
};
// tslint:disable-next-line:no-default-export
export default config;

View File

@@ -1,17 +1,8 @@
// tslint:disable:no-default-export
// tslint:disable:no-magic-numbers
import {RecursivePartial} from '@openstapps/logger/lib/common';
import {ElasticsearchConfigFile} from '../src/storage/elasticsearch/common';
/**
* A partial type which is recursive
*
* Copied and only modified array type from `[]` to `Array<>` from https://stackoverflow.com/a/51365037
*/
type RecursivePartial<T> = {
[P in keyof T]?:
T[P] extends Array<(infer U)> ? Array<RecursivePartial<U>> :
T[P] extends object ? RecursivePartial<T[P]> :
T[P];
};
/**
* This is the database configuration for the technical university of berlin
*/

View File

@@ -1,3 +1,5 @@
// tslint:disable:no-default-export
// tslint:disable:no-magic-numbers
import {ElasticsearchConfigFile} from '../src/storage/elasticsearch/common';
/**
@@ -8,8 +10,8 @@ import {ElasticsearchConfigFile} from '../src/storage/elasticsearch/common';
* To select your university specific configuration which is merged from this default file and your university specific
* file, you have to supply the `NODE_APP_INSTANCE` environment variable with your license plate
*
* To select a differen database you have to supply the `NODE_CONFIG_ENV` environment variable with a database name that
* is implemented in the backend
* To select a different database you have to supply the `NODE_CONFIG_ENV` environment variable with a database name
* that is implemented in the backend
*
* To get more information about the meaning of specific fields please use your IDE to read the TSDoc documentation.
*/