Skip to content

Commit

Permalink
no bug found
Browse files Browse the repository at this point in the history
  • Loading branch information
TZFC committed Dec 8, 2023
1 parent 53a98b1 commit 379b729
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions Utils/Checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,26 @@ async def record_checkin(start_time: datetime, end_time: datetime, master: str,
val = (master,)
cursor.execute(sql, val)
dedeuserid = int(cursor.fetchall()[0][0])
print(f"dedeuserid: {dedeuserid}")

sql = "SELECT slot_0, slot_1, slot_2, slot_3, slot_4, slot_5, slot_6, slot_7, slot_8, slot_9 FROM checkin WHERE uid = %s AND room_id = %s"
val = (dedeuserid, room_id)
cursor.execute(sql, val)
slots: tuple = cursor.fetchall()[0]
head = slots.index(1)
print(f"head: {head}")
next_head = head + 1 if head != 9 else 0
print(f"nexthead: {next_head}")

sql = "SELECT DISTINCT uid FROM danmu WHERE room_id = %s AND time BETWEEN %s AND %s"
val = (room_id, start_time, end_time)
cursor.execute(sql, val)
result = cursor.fetchall()
unique_uid = [item[0] for item in result]
print(f"unique_uid: {unique_uid}")

sql = f"UPDATE checkin SET slot_{head} = 0 WHERE room_id = %s"
val = (room_id,)
cursor.execute(sql, val)

sql = f"INSERT INTO checkin (room_id, uid, slot_{head}) VALUES(%s, %s, 1) ON DUPLICATE KEY UPDATE slot_{head} = 1"
val = [(room_id, uid) for uid in unique_uid if uid not in blacklist and uid != dedeuserid]
print(f"updated values: {val}")
cursor.executemany(sql, val)

sql = f"UPDATE checkin SET slot_{next_head} = 1 where room_id = %s AND uid = %s"
Expand Down

0 comments on commit 379b729

Please sign in to comment.