Overview
The Attendance Record model stores location-based check-in data for employees. Records are stored indata/registros.json as a JSON array, with each entry representing a single location submission.
Schema
Username of the employee who submitted the location. Automatically set to
current_user.id from the authenticated session.Source: Extracted from Flask-Login sessionExample: "empleado1"Latitude coordinate of the employee’s location at check-in time.Format: Decimal degreesRange: -90 to 90Example:
19.432608Longitude coordinate of the employee’s location at check-in time.Format: Decimal degreesRange: -180 to 180Example:
-99.133209Date of the attendance record. Automatically generated server-side when location is submitted.Format:
YYYY-MM-DDExample: "2026-03-05"Generation: datetime.datetime.now().strftime("%Y-%m-%d")Time of the attendance record. Automatically generated server-side when location is submitted.Format:
HH:MM:SS (24-hour format)Example: "08:15:30"Generation: datetime.datetime.now().strftime("%H:%M:%S")JSON Structure
Complete Example
Sampledata/registros.json file with multiple records:
Record Creation
Attendance records are created via the/update-location endpoint. Implementation (app.py:116-132):
Client Provides
lat(number)lon(number)
Server Generates
usuario(from session)fecha(current date)hora(current time)
Attendance Status
Records are evaluated for tardiness based on thehora field:
Record submitted at or before 08:30:00Condition:
hora <= "08:30:00"Display: Shown as “PUNTUAL” in monitor dashboard and PDF reportsRecord submitted after 08:30:00Condition:
hora > "08:30:00"Display: Shown as “RETARDO” in monitor dashboard and PDF reportsThe comparison is performed as a string comparison, which works correctly for the
HH:MM:SS format.Usage in Monitoring
The monitor dashboard uses attendance records to display:All Attendance Records
Shows every record with computed status:Active Users
Displays the most recent location for each user:Today’s Absences
Identifies users without records for the current date:Usage in Reports
PDF reports include all attendance records and compute tardiness statistics:Multiple Records Per Day
The system allows multiple location submissions per day:- Each submission creates a new record
- No deduplication or updating of existing records
- All records are preserved in chronological order
- The monitor dashboard shows all records, not just the first of the day
Data Persistence
Records are stored using JSON file operations:- Created empty on first run (app.py:37-39)
- Read entirely into memory for each operation
- Written entirely back to disk after modifications
- Formatted with 4-space indentation for readability
Coordinate Precision
The system accepts and stores coordinate values with arbitrary precision:- No rounding or truncation applied
- Stored as JSON numbers (float)
- Standard GPS coordinates have ~7 decimal places (~11mm precision)