(self, update: Update)
| 35 | raise Exception(f"Update with timestamp ({timestamp}) is lower than the last timestamp ({self.timestamp}). Invalid state.") |
| 36 | |
| 37 | def process(self, update: Update): |
| 38 | value = json.dumps(update['value']) |
| 39 | count = self.state.get(value, 0) + update['diff'] |
| 40 | |
| 41 | if count <= 0: |
| 42 | del self.state[value] |
| 43 | else: |
| 44 | self.state[value] = count |
| 45 | |
| 46 | if self.history is not None: |
| 47 | self.history.append(update) |
| 48 | |
| 49 | def update(self, updates: List[Update], timestamp: int): |
| 50 | if len(updates) > 0: |