Coverage for src / local_deep_research / database / models / logs.py: 92%
24 statements
« prev ^ index » next coverage.py v7.12.0, created at 2026-01-11 00:51 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2026-01-11 00:51 +0000
1"""
2Logging models for storing application logs and journal information.
3"""
5from sqlalchemy import (
6 Column,
7 ForeignKey,
8 Integer,
9 Sequence,
10 String,
11 Text,
12)
13from sqlalchemy_utc import UtcDateTime, utcnow
15from .base import Base
18class ResearchLog(Base):
19 """
20 Logging table for all research operations.
22 All logging from research operations, including debug messages,
23 errors, and milestones are stored here.
24 """
26 __tablename__ = "app_logs"
28 id = Column(
29 Integer, Sequence("reseach_log_id_seq"), primary_key=True, index=True
30 )
32 timestamp = Column(UtcDateTime, server_default=utcnow(), nullable=False)
33 message = Column(Text, nullable=False)
34 # Module that the log message came from.
35 module = Column(Text, nullable=False)
36 # Function that the log message came from.
37 function = Column(Text, nullable=False)
38 # Line number that the log message came from.
39 line_no = Column(Integer, nullable=False)
40 # Log level.
41 level = Column(String(32), nullable=False)
42 research_id = Column(
43 String(36), # UUID as string
44 ForeignKey("research_history.id", ondelete="CASCADE"),
45 nullable=True,
46 index=True,
47 )
49 def __repr__(self):
50 return f"<ResearchLog({self.level}: '{self.message[:50]}...')>"
53class Journal(Base):
54 """
55 Information about academic journals for quality scoring.
56 """
58 __tablename__ = "journals"
60 id = Column(
61 Integer, Sequence("journal_id_seq"), primary_key=True, index=True
62 )
64 # Name of the journal
65 name = Column(String(255), nullable=False, unique=True, index=True)
66 # Quality score of the journal
67 quality = Column(Integer, nullable=True)
68 # Model that was used to generate the quality score.
69 quality_model = Column(String(255), nullable=True, index=True)
70 # Time at which the quality was last analyzed.
71 quality_analysis_time = Column(Integer, nullable=False)
73 def __repr__(self):
74 return f"<Journal(name='{self.name}', quality={self.quality})>"