@@ -1286,6 +1286,7 @@ class CognitionMessage(Base):
12861286 ),
12871287 index = True ,
12881288 )
1289+ initiated_via = Column (String ) # of type enums.MessageInitiationType.*.value
12891290
12901291
12911292class CognitionPipelineLogs (Base ):
@@ -2453,3 +2454,37 @@ class SumsTable(Base):
24532454 sum_key = Column (String , index = True ) # e.g. enums.AdminQueries
24542455 created_at = Column (DateTime , default = sql .func .now ())
24552456 data = Column (JSON )
2457+
2458+
2459+ class AdminQueryMessageSummary (Base ):
2460+ __tablename__ = Tablenames .ADMIN_QUERY_MESSAGE_SUMMARY .value
2461+ __table_args__ = (
2462+ UniqueConstraint (
2463+ "organization_id" ,
2464+ "project_id" ,
2465+ "day" ,
2466+ name = "unique_admin_query_msg_activity_summary" ,
2467+ ),
2468+ {"schema" : "cognition" },
2469+ )
2470+ id = Column (UUID (as_uuid = True ), primary_key = True , default = uuid .uuid4 )
2471+ day = Column (Date , nullable = False )
2472+ organization_id = Column (
2473+ UUID (as_uuid = True ),
2474+ ForeignKey (f"{ Tablenames .ORGANIZATION .value } .id" , ondelete = "CASCADE" ),
2475+ )
2476+ project_id = Column (
2477+ UUID (as_uuid = True ),
2478+ ForeignKey (f"cognition.{ Tablenames .PROJECT .value } .id" , ondelete = "SET NULL" ),
2479+ )
2480+
2481+ total_conversations = Column (Integer , default = 0 )
2482+ total_messages = Column (Integer , default = 0 )
2483+ messages_via_api = Column (Integer , default = 0 )
2484+ messages_via_ui = Column (Integer , default = 0 )
2485+ messages_via_macro = Column (Integer , default = 0 )
2486+ confidential_messages = Column (Integer , default = 0 )
2487+ kern_user_messages = Column (Integer , default = 0 )
2488+ deleted_messages_by_user = Column (Integer , default = 0 )
2489+ deleted_messages_by_system = Column (Integer , default = 0 )
2490+ incognito_messages = Column (Integer , default = 0 )
0 commit comments