forked from long2ice/meilisync
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add insert size and insert interval
- Loading branch information
Showing
6 changed files
with
146 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from meilisync.enums import EventType | ||
from meilisync.schemas import Event | ||
from meilisync.settings import Sync | ||
|
||
|
||
class EventCollection: | ||
def __init__(self): | ||
self._size = 0 | ||
self._events = {} | ||
|
||
def add_event(self, sync: Sync, event: Event): | ||
pk = event.data[sync.pk] | ||
self._events.setdefault(sync, {}) | ||
self._events[sync][pk] = event | ||
|
||
@property | ||
def size(self): | ||
return self._size | ||
|
||
@property | ||
def pop_events(self): | ||
updated_events = {} | ||
created_events = {} | ||
deleted_events = {} | ||
for sync, events in self._events.items(): | ||
updated_events[sync] = [] | ||
created_events[sync] = [] | ||
deleted_events[sync] = [] | ||
for event in events.values(): | ||
if event.type == EventType.create: | ||
created_events[sync].append(event) | ||
elif event.type == EventType.update: | ||
updated_events[sync].append(event) | ||
elif event.type == EventType.delete: | ||
deleted_events[sync].append(event) | ||
self._events = {} | ||
self._size = 0 | ||
return created_events, updated_events, deleted_events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters