-
Notifications
You must be signed in to change notification settings - Fork 0
/
formula.py
50 lines (43 loc) · 1.79 KB
/
formula.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import abc
import decimal
import typing
from uuid import UUID
from models import MaturaResults
class CodeFormula:
# Set to initial year of concrete formula implementation. It will not affect what recruitment will be available for.
year: typing.Optional[int] = None
uuid: typing.Optional[UUID] = None # MUST BE ALWAYS BE SET TO NEW UUID
min_score: int = 0
max_score: float = 100
def __init__(
self,
*,
field_of_study_id: typing.Optional[int] = None,
formula_year: typing.Optional[int] = None,
threshold: typing.Optional[float] = None,
threshold_year: typing.Optional[int] = None,
is_official_threshold: typing.Optional[bool] = None,
special_requirements: typing.Optional[bool] = None,
university_id: typing.Optional[int] = None,
department_id: typing.Optional[int] = None,
):
"""
You do not need to use this fields
can be not available during calculation (as you can see - all fields are optional)
"""
self.field_of_study_id = field_of_study_id
self.formula_year = formula_year or self.year
self.threshold = threshold
self.threshold_year = threshold_year
self.is_official_threshold = is_official_threshold
self.special_requirements = special_requirements
self.university_id = university_id
self.department_id = department_id
@staticmethod
def round(n: typing.Union[int, float, decimal.Decimal]) -> int:
"""Proper rounding method"""
return int(decimal.Decimal(n).to_integral(decimal.ROUND_HALF_UP))
@abc.abstractmethod
def calculate(self, matura_results: MaturaResults) -> float:
"""You should implement your algorithm here"""
pass