feat: updated docs and added description to files
Some checks failed
Tests / Run Go Tests (push) Failing after 1m35s
Arbeitszeitmessung Deploy / Build Webserver (push) Successful in 2m48s

This commit is contained in:
2026-01-29 18:28:28 +01:00
parent 41c34c42cf
commit ba034f1c33
52 changed files with 458 additions and 3413 deletions

View File

@@ -1,8 +1,19 @@
// the models package contains the datamodels for the whole webserver
// most of them are also in the DB
//
// in the future it would be good to change it to create a repository structure,
// so that there would be a second pacakge handling db requests
package models
// this file has all functions and types to handle absences
// the absence type implements the iWorkDay interface so that
// it can be used as one workday
//
// the absence data is based on the entries in the "abwesenheit" database table
import (
"encoding/json"
"errors"
"log"
"time"
)
@@ -27,25 +38,6 @@ func (a *Absence) IsEmpty() bool {
return false
}
func NewAbsence(card_uid string, abwesenheit_typ int, datum time.Time) (Absence, error) {
if abwesenheit_typ < 0 {
return Absence{
CardUID: card_uid,
AbwesenheitTyp: AbsenceType{0, "Custom absence", 100},
DateFrom: datum,
}, nil
}
_absenceType, ok := GetAbsenceTypesCached()[int8(abwesenheit_typ)]
if !ok {
return Absence{}, errors.New("Invalid absencetype")
}
return Absence{
CardUID: card_uid,
AbwesenheitTyp: _absenceType,
DateFrom: datum,
}, nil
}
func (a *Absence) Date() time.Time {
return a.Day.Truncate(24 * time.Hour)
}