From 96019367e8f72eac26abd3b7a908c2b914bd1ae1 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 17 Nov 2023 13:24:42 -0800 Subject: v2: add initial Next JS files, remove static templates --- html_builders/tables.py | 74 ------------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 html_builders/tables.py (limited to 'html_builders/tables.py') diff --git a/html_builders/tables.py b/html_builders/tables.py deleted file mode 100644 index a1d3a62..0000000 --- a/html_builders/tables.py +++ /dev/null @@ -1,74 +0,0 @@ -def generate_html_table(server, table, diff_table, headers=["Rank", "Liver", "Subscriber", "Difference (24hr)"]): - def get_daily_difference_subs(sub_count_str: str): - diff_cursor = server.get_connection().cursor() - diff_cursor.execute(query) - diff_data = diff_cursor.fetchall() - if len(diff_data) == 0: - return "N/A" - old_sub_count = int(diff_data[0][0]) - current_sub_count = int(sub_count_str) - if old_sub_count > current_sub_count: - return f"-{old_sub_count - current_sub_count}" - else: - return f"+{current_sub_count - old_sub_count}" - cursor = server.get_connection().cursor() - query = f"SELECT id, channel_id, name, subscriber_count, timestamp, profile_pic FROM {table} ORDER by subscriber_count DESC" - cursor.execute(query) - data = cursor.fetchall() - header = "" - for h in headers: - header += f"{h}" - header += "" - table_html = "" - table_html += header - rank = 1 - for row in data: - table_row = "" - table_row += f"" - rank += 1 - for i, col in enumerate(row): - if cursor.description[i][0] == "name": - channel_url = f"/stats/{row[2]}" - profile_pic_url = row[5] - table_row += f"" - elif cursor.description[i][0] == "subscriber_count": - formatted_sub_count = "{:,.0f}".format(int(col)) - table_row += f"" - elif cursor.description[i][0] == "timestamp": - query = f"SELECT sub_diff FROM {diff_table} WHERE channel_id = '{row[1]}'" - try: - table_row += f"" - except IndexError: - raise Exception("Are you trying to use a new set of channels?\nPlease delete last_refresh.txt in data folder first!") - elif cursor.description[i][0] not in ["id", "channel_id", "profile_pic"]: - table_row += f"" - table_row += "" - table_html += table_row - table_html += "
{rank}{col}{formatted_sub_count}{get_daily_difference_subs(row[3])}{col}
" - cursor.close() - return table_html - -def generate_individual_table(server, table_name, channel_name, param=""): - cursor = server.get_connection().cursor() - query = f"SELECT subscriber_count, timestamp FROM {table_name} WHERE name=\"{channel_name}\" GROUP BY DATE(timestamp) ORDER by timestamp DESC " + param - cursor.execute(query) - data = cursor.fetchall() - table = "" - header = "" - header_cols = ["Subscribers", "Timestamp"] - for col in header_cols: - header += f"" - header += "" - table += header - for row in data: - table += "" - for i, col in enumerate(row): - if cursor.description[i][0] == "subscriber_count": - formatted_sub_count = "{:,.0f}".format(int(col)) - table += f"" - else: - table += f"" - table += "" - table += "
{col}
{formatted_sub_count}{col}
" - cursor.close() - return table \ No newline at end of file -- cgit v1.2.3