build.utils.db_api.unban_members.unban_member()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
# -*- coding: utf-8 -*-
2
3
4
from utils.db_api.creat_db import cursor
5
6
7
"""
8
9
10
    Created on 24.09.2021
11
    
12
    @author: Nikita
13
14
15
"""
16
17
18
async def unban_member(user_id, ban_time):
19
20
    """
21
22
    The function is designed to unban the chat user.
23
24
    """
25
26
    del_members = f"DELETE from banned_chat_members WHERE time_out < DATE_SUB(NOW(), INTERVAL {ban_time} SECOND)"
27
28
    add_members = f"""SELECT user_id FROM banned_chat_members WHERE user_id={user_id}"""
29
30
    cursor.execute(del_members)
31
    cursor.execute(add_members)
32
33
    result = cursor.fetchall()
34
    result = [row[0] for row in result]
35
36
    return result
37