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;