Skip to content

Conversation

Copy link

Copilot AI commented Sep 13, 2025

This PR completes the logging system cleanup by implementing the missing Report Log table, as outlined in the issue requirements. The existing monolithic log table was identified as problematic, and this change adds the final specialized logging table needed.

What's Changed

🆕 New ReportLog Table

  • Created ReportLog model following the same pattern as other specialized log tables
  • Added ReportLogEvent enum with comprehensive event types:
    • CREATE, DELETE - Report lifecycle
    • START, PROGRESS, FINISH, ERROR - Generation tracking
    • VIEW, DOWNLOAD, SHARE - Access and distribution
    • EDIT - Configuration changes

🔗 Database Relationships

  • Report.report_logs → All log entries for a specific report
  • User.report_logs → All report actions performed by a user
  • Course.report_logs → All report logs within course context
  • Assignment.report_logs → All report logs for assignment context

📊 Table Structure

CREATE TABLE report_log (
    id INTEGER PRIMARY KEY,
    report_id INTEGER REFERENCES report(id),
    subject_id INTEGER REFERENCES user(id), 
    course_id INTEGER REFERENCES course(id),     -- Optional context
    assignment_id INTEGER REFERENCES assignment(id), -- Optional context
    event_type VARCHAR(255),                     -- ReportLogEvent enum
    field VARCHAR(255),                          -- For EDIT events
    value TEXT,                                  -- For EDIT events  
    client_timestamp VARCHAR(255),
    client_timezone VARCHAR(255),
    -- Standard audit fields
    date_created TIMESTAMP,
    date_modified TIMESTAMP
);

✅ Complete Specialized Logging System

All specialized log tables are now implemented:

  • AccessLog - User access and page requests
  • AssignmentLog - Assignment creation, editing, deletion
  • CourseLog - Course management events
  • ErrorLog - Application errors and exceptions
  • RoleLog - Role assignments and permissions
  • SubmissionLog - Student code submissions and feedback
  • ReportLog - Report generation and sharing events ← New

Usage Example

from models.log_tables import ReportLog
from models.enums import ReportLogEvent

# Log report creation
ReportLog.new(
    report_id=123,
    subject_id=456,
    event_type=ReportLogEvent.CREATE,
    course_id=789
)

# Log progress update
ReportLog.new(
    report_id=123, 
    subject_id=456,
    event_type=ReportLogEvent.PROGRESS,
    field='progress',
    value='75'
)

Migration Included

Database migration script provided to create the new table with proper indexes and foreign key constraints.

This change provides better performance, clearer data organization, and easier maintenance compared to the monolithic log table approach. The existing log table can continue to work alongside these specialized tables during migration.

Fixes #57.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits September 13, 2025 03:02
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Copilot AI changed the title [WIP] Clean up logging Complete logging cleanup by implementing ReportLog table Sep 13, 2025
Copilot AI requested a review from acbart September 13, 2025 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up logging

2 participants