Skip to content

Commit 06417dc

Browse files
committed
fix: remove debug print statement in consent_manager.py
refactor: comment out profile ID mismatch warning in event_computer.py style: remove extra newline in config.py perf: adjust timeout in event_source.py to 1 second feat: add multiple indexes to mysql schema tables for optimization chore: remove unused code from mysql schema table definitions fix: simplify error message in source_validation.py
1 parent 8b072f2 commit 06417dc

File tree

4 files changed

+15
-78
lines changed

4 files changed

+15
-78
lines changed

tracardi/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def __init__(self):
4646
logger.info(f"EVENT_TO_PROFILE_COPY_CACHE_TTL={self.event_to_profile_coping_ttl}")
4747
logger.info(f"SOURCE_CACHE_TTL={self.source_ttl}")
4848

49-
5049
class MysqlConfig:
5150

5251
def __init__(self, env):

tracardi/service/cache/event_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@AsyncCache(memory_cache.source_ttl,
10-
timeout=.5,
10+
timeout=1,
1111
max_one_cache_fill_every=.1,
1212
return_cache_on_error=True
1313
)

tracardi/service/storage/mysql/schema/table.py

Lines changed: 13 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class WorkflowTriggerTable(Base):
123123

124124
__table_args__ = (
125125
PrimaryKeyConstraint('id', 'tenant', 'production'),
126+
Index('idx_collector', 'event_type_id', 'source_id', 'enabled', 'tenant', 'production'),
126127
)
127128

128129
running: bool = False
@@ -237,6 +238,8 @@ class DestinationTable(Base):
237238

238239
__table_args__ = (
239240
PrimaryKeyConstraint('id', 'tenant', 'production'),
241+
Index('idx_collector', 'event_type_id', 'source_id', 'enabled', 'tenant', 'production'),
242+
240243
)
241244

242245
running: bool = False
@@ -298,6 +301,7 @@ class IdentificationPointTable(Base):
298301

299302
__table_args__ = (
300303
PrimaryKeyConstraint('id', 'tenant', 'production'),
304+
Index('idx_collector', 'tenant', 'production', 'enabled', 'event_type_id', 'source_id')
301305
)
302306

303307
running: bool = False
@@ -335,6 +339,7 @@ class EventRedirectTable(Base):
335339

336340
__table_args__ = (
337341
PrimaryKeyConstraint('id', 'tenant', 'production'),
342+
Index('idx_collector', 'event_type', 'source_id', 'tenant', 'production'),
338343
)
339344

340345
running: bool = False
@@ -356,6 +361,7 @@ class EventValidationTable(Base):
356361

357362
__table_args__ = (
358363
PrimaryKeyConstraint('id', 'tenant', 'production'),
364+
Index('idx_collector', 'event_type', 'enabled', 'tenant', 'production'),
359365
)
360366

361367
running: bool = False
@@ -402,6 +408,7 @@ class EventReshapingTable(Base):
402408

403409
__table_args__ = (
404410
PrimaryKeyConstraint('id', 'tenant', 'production'),
411+
Index('idx_collector', 'event_type', 'tenant', 'production', 'enabled')
405412
)
406413

407414
running: bool = False
@@ -425,7 +432,8 @@ class EventMappingTable(Base):
425432

426433
__table_args__ = (
427434
PrimaryKeyConstraint('id', 'tenant', 'production'),
428-
UniqueConstraint('event_type', name='uiq_event_type')
435+
UniqueConstraint('event_type', name='uiq_event_type'),
436+
Index('idx_collector', 'event_type', 'tenant', 'production', 'enabled')
429437
)
430438

431439
running: bool = False
@@ -496,6 +504,7 @@ class EventToProfileMappingTable(Base):
496504

497505
__table_args__ = (
498506
PrimaryKeyConstraint('id', 'tenant', 'production'),
507+
Index('idx_collector', 'event_type_id', 'tenant', 'production', 'enabled')
499508
)
500509

501510
running: bool = False
@@ -517,6 +526,7 @@ class EventDataComplianceTable(Base):
517526

518527
__table_args__ = (
519528
PrimaryKeyConstraint('id', 'tenant', 'production'),
529+
Index('idx_collector', 'event_type_id', 'tenant', 'production', 'enabled')
520530
)
521531

522532
running: bool = False
@@ -546,27 +556,6 @@ class ActivationTable(Base):
546556
running: bool = False
547557

548558

549-
# class SegmentTable(Base):
550-
# __tablename__ = 'segment'
551-
#
552-
# id = Column(String(40))
553-
# name = Column(Text)
554-
# description = Column(Text)
555-
# event_type = Column(String(64), default=None)
556-
# condition = Column(Text)
557-
# enabled = Column(Boolean, default=False)
558-
# machine_name = Column(String(128))
559-
#
560-
# tenant = Column(String(40))
561-
# production = Column(Boolean)
562-
#
563-
# __table_args__ = (
564-
# PrimaryKeyConstraint('id', 'tenant', 'production'),
565-
# )
566-
#
567-
# running: bool = False
568-
569-
570559
class ReportTable(Base):
571560
__tablename__ = 'report'
572561

@@ -587,31 +576,7 @@ class ReportTable(Base):
587576

588577
running: bool = False
589578

590-
591-
# class ContentTable(Base):
592-
# __tablename__ = 'content'
593-
#
594-
# id = Column(String(48))
595-
# profile_id = Column(String(40))
596-
# timestamp = Column(DateTime)
597-
# type = Column(String(64))
598-
# url = Column(String(255))
599-
# source = Column(String(128))
600-
# author = Column(String(96))
601-
# copyright = Column(String(128))
602-
# content = Column(BLOB)
603-
# text = Column(Text)
604-
# properties = Column(JSON)
605-
# traits = Column(JSON)
606-
#
607-
# tenant = Column(String(40))
608-
# production = Column(Boolean)
609-
#
610-
# __table_args__ = (
611-
# PrimaryKeyConstraint('id', 'tenant', 'production'),
612-
# )
613-
614-
579+
# TODO probably not used
615580
class ImportTable(Base):
616581
__tablename__ = 'import'
617582

@@ -637,32 +602,6 @@ class ImportTable(Base):
637602
running: bool = False
638603

639604

640-
# class WorkflowSegmentationTriggerTable(Base):
641-
# __tablename__ = 'workflow_segmentation_trigger'
642-
#
643-
# id = Column(String(40))
644-
# timestamp = Column(DateTime)
645-
# name = Column(String(128))
646-
# description = Column(Text)
647-
# enabled = Column(Boolean, default=False)
648-
# type = Column(String(32))
649-
# condition = Column(String(255))
650-
# operation = Column(String(32))
651-
# segment = Column(String(128))
652-
# code = Column(Text)
653-
# workflow_id = Column(String(40))
654-
# workflow_name = Column(String(128))
655-
#
656-
# tenant = Column(String(40))
657-
# production = Column(Boolean)
658-
#
659-
# __table_args__ = (
660-
# PrimaryKeyConstraint('id', 'tenant', 'production'),
661-
# )
662-
#
663-
# running: bool = False
664-
665-
666605
class TaskTable(Base):
667606
__tablename__ = 'task'
668607

@@ -681,6 +620,7 @@ class TaskTable(Base):
681620

682621
__table_args__ = (
683622
PrimaryKeyConstraint('id', 'tenant', 'production'),
623+
Index('idx_gui', 'type', 'tenant', 'production')
684624
)
685625

686626
running: bool = False

tracardi/service/tracking/source_validation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ async def _validate_source(tracker_payload: TrackerPayload, allowed_bridges) ->
6666
if source is None:
6767
context = get_context()
6868
raise BlockedException(f"Invalid event source `{source_id}` for tenant `{context.tenant}`. "
69-
f"Tenant or event source may not exit. "
70-
f"Request came from IP: `{ip}` "
71-
f"width payload: {tracker_payload}")
69+
f"Tenant or event source may not exit. ")
7270

7371
if source.has_restricted_domain():
7472
origin = tracker_payload.get_origin_or_referer()

0 commit comments

Comments
 (0)