Meeting Lifecycle Management
Purpose
Within the broader scope of Real-Time Meeting Cost Tracking (Main Topic), the Meeting Lifecycle Management subtopic addresses the orchestration of meeting session states—specifically starting, stopping, resetting, and dynamically applying changes to attendee counts and hourly wages during an active meeting. This management ensures that meeting time segments are accurately recorded with their respective parameters, enabling precise cost calculations and data persistence.
While the parent topic describes the continuous cost updating process, this subtopic focuses on controlling the meeting's temporal boundaries and state transitions, maintaining coherent data slices (increments) that reflect attendee and wage changes over time.
Functionality
Meeting State Control
Start Meeting: Initializes meeting state by clearing previous increments, setting the clock running flag, and recording the start time of the first increment.
Stop Meeting: Halts the meeting clock, pushes the final increment capturing the elapsed time and parameters since the last update, and triggers saving the collected increments to persistent storage via the warehouse.
Reset Meeting: Resets all meeting-related data to default values, clearing increments, stopping the clock, and preparing the system for a fresh meeting session.
Dynamic Updates During Meetings
When the attendee count or average wage is changed mid-meeting, the system:
Pushes the current increment capturing the elapsed time and cost with previous parameters.
Starts a new increment from the current time with updated parameters.
The meeting purpose can be updated anytime without affecting increments, as it is a descriptive attribute attached to the meeting.
Increment Management
The lifecycle methods ensure increments are pushed only when meaningful (e.g., on attendee/wage change or stop).
Each increment represents a discrete time interval with consistent attendee count and wage data.
The method
pushIncrement():Instantiates a new
Incrementobject using the start time of the current increment, current time, attendee count, wage, and cumulative total cost.Updates the start time for the next increment to the current time.
Real-Time Calculations Integration
getTotalCost()andgetTotalTime()methods return cumulative values by adding the cost/time of completed increments plus the ongoing increment (if the meeting is running).This supports the real-time cost display managed by related subtopics like Incremental Cost Calculation and Dynamic Cost Visualization.
Integration
The
Meetingclass bridges user actions captured in the UI (User Interaction and Interface) and low-level cost calculations.It coordinates with the
Warehousemodel for saving increments after a meeting ends, enabling persistence handled by Persistent Meeting History.Event handlers in index.js invoke lifecycle methods on user button interactions (
startMeeting(),stopMeeting(),resetMeeting()), and on change events for attendee count, wage, and purpose.This subtopic's management of increments ensures that cost calculations receive accurate and segmented data reflecting temporal changes, which feeds into continuous updates and visualization.
Code Snippet Illustrating Lifecycle Control
// Starting the meeting resets increments and starts the clock
meeting.startMeeting();
// On attendee count change mid-meeting
meeting.changeAttendeeCount(newCount); // pushes previous increment, starts new increment
// Stopping the meeting pushes final increment and saves data
meeting.stopMeeting();
sequenceDiagram
participant User
participant UI
participant Meeting
participant Warehouse
User->>UI: Click Start
UI->>Meeting: startMeeting()
Meeting->>Meeting: clockRunning = true; currentIncrementStartTime = now
Meeting-->>UI: Meeting started
User->>UI: Change Attendee Count or Wage
UI->>Meeting: changeAttendeeCount() / changeAverageWage()
Meeting->>Meeting: pushIncrement() with old params
Meeting->>Meeting: update currentIncrementStartTime and params
Meeting-->>UI: Updated increment started
User->>UI: Click Stop
UI->>Meeting: stopMeeting()
Meeting->>Meeting: pushIncrement() final
Meeting->>Warehouse: save(increments)
Warehouse-->>Meeting: confirm save
Meeting-->>UI: Meeting stopped, data saved
User->>UI: Click Reset
UI->>Meeting: resetMeeting()
Meeting->>Meeting: reset all state to defaults
Meeting-->>UI: Meeting reset
This sequence diagram highlights the interaction flow between user actions, UI event handling, meeting state transitions, and data persistence, encapsulated within the lifecycle management subtopic.