Skip to content

Commit

Permalink
ignore old events
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Sep 26, 2024
1 parent be53f7f commit 655ee86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/debezium.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from datetime import datetime

import msgspec


class Source(msgspec.Struct):
ts_ms: int

def timestamp(self) -> datetime:
return datetime.fromtimestamp(self.ts_ms / 1000).astimezone()


class ChiiNotify(msgspec.Struct):
"""table of chii_notify as json"""

Expand Down Expand Up @@ -39,3 +48,4 @@ class MemberValue(msgspec.Struct):
before: ChiiMember | None
after: ChiiMember | None
op: str # 'r', 'c', 'd' ...
source: Source
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ async def handle_member(self, msg: Msg):
except msgspec.ValidationError:
return

# ignore events before 2024-09-26T01:06:26+00:00
if value.source.ts_ms < 1727312791000:
return

if value.op != "u":
return

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ ignore = [
'S104',
'C901',
'ISC003',
'PLR0911',
'PLR0913',
'RUF001',
'SIM108',
Expand Down

0 comments on commit 655ee86

Please sign in to comment.