Added delta for record deduplication
This commit is contained in:
parent
84e5f9295f
commit
b612e18955
@ -1,5 +1,7 @@
|
||||
import sys
|
||||
import typing
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
import aiohttp
|
||||
import discord
|
||||
@ -70,7 +72,7 @@ class RecordBatchStore(typing.Generic[T]):
|
||||
|
||||
|
||||
class Bot(discord.Client):
|
||||
last_insert: dict[int, typing.Any] = {}
|
||||
last_insert: dict[int, datetime] = {}
|
||||
track_store: RecordBatchStore[SpotifyRecord] = RecordBatchStore(submit_records, 1)
|
||||
|
||||
async def on_ready(self):
|
||||
@ -83,7 +85,8 @@ class Bot(discord.Client):
|
||||
return
|
||||
|
||||
spotify: discord.Spotify
|
||||
if self.last_insert.get(user_id) == spotify.created_at:
|
||||
last_insert = self.last_insert.get(user_id)
|
||||
if last_insert and last_insert - spotify.created_at > timedelta(seconds=15):
|
||||
return
|
||||
|
||||
self.last_insert[user_id] = spotify.created_at
|
||||
|
Loading…
x
Reference in New Issue
Block a user