fixes #4 - adds modular analyses system using plugins

This commit is contained in:
2025-02-10 02:12:12 +01:00
parent 59fed26abf
commit e57869374b
22 changed files with 1018 additions and 179 deletions

View File

@@ -0,0 +1,33 @@
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from .basePlotAnalysis import BasePlotAnalysis
from flask import current_app, url_for
from app.logging_config import get_logger
import matplotlib
matplotlib.use('Agg')
logger = get_logger()
class PlotTopActiveUsers(BasePlotAnalysis):
name = "Top Active Users"
description = "Displays the most active users based on their number of recorded actions."
plot_filename = "bar_activity-per-user.png"
note = ""
def transform_data(self, df: pd.DataFrame) -> pd.DataFrame:
"""Transform data for the bar plot"""
df = df[df['was_active'] == True].groupby('name').size().reset_index(name='active_count')
return df
def plot_data(self, df: pd.DataFrame):
"""Generate bar plot"""
# create a barplot from active counts sorted by active count
plt.figure(figsize=(10, 6))
sns.barplot(x='active_count', y='name', data=df.sort_values('active_count', ascending=False))
plt.xticks(rotation=90)
plt.title('Minutes Active')
plt.xlabel('Player')
plt.ylabel('Active Count')