Skip to content

Commit

Permalink
Aggiunti animatori del pranzo condiviso
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiaOldani committed Jul 7, 2024
1 parent b0bab7a commit 20b72ca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions generator/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
FORM_API_KEY=
FORM_ENDPOINT=
ANIMATORS_PER_SLOT=
ANIMATORS_SHARE_LUNCH=
MAX_NUMBER_DAILY_SLOTS=
MAX_REPETITION_SAME_SLOT=

Expand Down
13 changes: 8 additions & 5 deletions generator/form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ def generate_dat_file():

authcode = base64.b64encode(f"{FORM_API_KEY}:ciao".encode()).decode()
headers = {"Authorization" : f"Basic {authcode}"}
params = {"pageSize": 100}

entries = requests.get(FORM_ENDPOINT, headers=headers).json()["Entries"]
entries = requests.get(FORM_ENDPOINT, headers=headers, params=params).json()["Entries"]

PRE = ["Field105", "Field106", "Field107", "Field108", "Field109"]
MENSA = ["Field305", "Field306", "Field307", "Field309"]
MENSA = ["Field305", "Field306", "Field307", "Field308", "Field309"]
POST = ["Field205", "Field206", "Field207", "Field208", "Field209"]

turns = dict()
names = list()
for entry in entries:
surname = ''.join(entry["Field2"].strip().split(" "))
name = surname + ''.join(entry["Field1"].strip().split(" "))
surname = ''.join([s.capitalize() for s in entry["Field2"].strip().replace("'", "").split(" ")])
name = surname + ''.join([n.capitalize() for n in entry["Field1"].strip().replace("'", "").split(" ")])
names.append(name)

pre = list()
Expand All @@ -38,7 +39,6 @@ def generate_dat_file():
mensa = list()
for field in MENSA:
mensa.append("0" if entry[field] == "" else "1")
mensa.insert(3,'0')

post = list()
for field in POST:
Expand Down Expand Up @@ -71,6 +71,9 @@ def generate_dat_file():
ANIMATORS_PER_SLOT = environment["ANIMATORS_PER_SLOT"]
f.write(f"param AnimatoriPerTurno := {ANIMATORS_PER_SLOT};\n\n")

ANIMATORS_SHARE_LUNCH = environment["ANIMATORS_SHARE_LUNCH"]
f.write(f"param AnimatoriPranzoCondiviso := {ANIMATORS_SHARE_LUNCH};\n\n")

MAX_REPETITION_SAME_SLOT = environment["MAX_REPETITION_SAME_SLOT"]
f.write(
f"param MassimaRipetizioneStessoTurno := {MAX_REPETITION_SAME_SLOT};\n\n"
Expand Down
7 changes: 5 additions & 2 deletions generator/turni.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set Animatori;
param Disponibilita {Giorni, Animatori, FasceOrarie} binary;
# Numero di animatori richiesti per turno
param AnimatoriPerTurno;
# Numero di animatori richiesti al pranzo condiviso
param AnimatoriPranzoCondiviso;
# Massimo numero di ripetizioni dello stesso turno
param MassimaRipetizioneStessoTurno;
# Numero di turni che ogni animatore fa al massimo in un giorno
Expand All @@ -30,8 +32,9 @@ var MinimoNumeroTurni integer;
# Presenza di <AnimatoriPerTurno> animatori per turno, esclusa la mensa del giovedi
subject to MinimoNumeroAnimatori {g in Giorni, fo in FasceOrarie : g <> '04_Giovedi' or fo <> '02_Mensa'}:
sum {a in Animatori} Assegnamento[g,a,fo] = AnimatoriPerTurno;
subject to MensaGiovediNoTurno:
sum {a in Animatori} Assegnamento['04_Giovedi',a,'02_Mensa'] = 0;
# Presenza di <AnimatoriPranzoCondiviso> animatori per turno, esclusa la mensa del giovedi
subject to NumeroAnimatoriPranzoCondiviso:
sum {a in Animatori} Assegnamento['04_Giovedi',a,'02_Mensa'] = AnimatoriPranzoCondiviso;
# Definizione del numero di turni
subject to DefinizioneNumeroTurni {a in Animatori}:
NumeroTurni[a] = sum {g in Giorni, fo in FasceOrarie} Assegnamento[g,a,fo];
Expand Down

0 comments on commit 20b72ca

Please sign in to comment.