Spaces:
Sleeping
Sleeping
| 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 | |