Spaces:
Sleeping
Sleeping
File size: 3,470 Bytes
a191da0 |
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
from . import *
from .Calendar import Calendar
from .Meeting import Meeting
from .Project import Project
from .Resource import Resource
from .Task import Task
def propose_meeting(
label: str,
desired_start: datetime,
duration: timedelta,
attendees: List[Resource]
) -> Optional[Meeting]:
"""
Proponi una nuova riunione. Controlla i calendari delle risorse (attendees)
per assicurarti che non ci siano sovrapposizioni e che non si crei overbooking.
Ritorna la riunione creata se c'è disponibilità, altrimenti None.
"""
# Creiamo un meeting "ipotetico"
new_meeting = Meeting(
label=label,
date=desired_start,
duration=duration,
notes="",
transcript=""
)
# Controlliamo la disponibilità di tutti i partecipanti
for attendee in attendees:
if attendee.calendar is None:
# Se la risorsa non ha un calendario, diamo per scontato che sia libera
continue
for existing_meeting in attendee.calendar.meetings:
# Verifichiamo se si sovrappone
if not (
new_meeting.end_datetime <= existing_meeting.date or
new_meeting.date >= existing_meeting.end_datetime
):
# C'è sovrapposizione
print(f"Riunione in conflitto per {attendee.first_name} {attendee.last_name}.")
return None
# Se non ci sono conflitti, aggiungiamo la riunione ai calendari di tutti
for attendee in attendees:
if attendee.calendar is None:
# Se non esiste un calendario, creiamone uno
attendee.calendar = Calendar(name=f"Calendario di {attendee.first_name}", meetings=[])
attendee.calendar.meetings.append(new_meeting)
print("Riunione creata con successo!")
return new_meeting
def query_meeting_transcript(meetings: List[Meeting], query: str) -> List[str]:
"""
Esempio di funzione per interrogare i testi trascritti delle riunioni.
In un contesto reale, potresti usare un modello LLM per cercare la risposta nel testo.
Qui ritorniamo semplicemente le righe in cui compare la query.
"""
results = []
for m in meetings:
if m.transcript and query.lower() in m.transcript.lower():
results.append(
f"'{query}' trovato nella riunione '{m.label}' in data {m.date}. "
f"Contesto: {m.transcript}"
)
return results
def update_repository_with_tasks(
project: Project,
new_tasks: List[Task],
tasks_to_remove: List[str],
tasks_to_update: List[Task]
) -> Project:
"""
Esempio di funzione per aggiornare un "repository" (qui, semplificato in un oggetto Project).
- new_tasks: Task da aggiungere
- tasks_to_remove: Nome dei Task da rimuovere
- tasks_to_update: Task da aggiornare (stesso name del task esistente)
Ritorna il progetto aggiornato.
"""
# 1. Rimuovi i task vecchi
project.tasks = [t for t in project.tasks if t.name not in tasks_to_remove]
# 2. Aggiungi i task nuovi
for nt in new_tasks:
project.tasks.append(nt)
# 3. Aggiorna i task esistenti
for update_t in tasks_to_update:
for i, existing_t in enumerate(project.tasks):
if existing_t.name == update_t.name:
# Aggiorna i campi necessari
project.tasks[i] = update_t
break
return project
|