Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions database/queries/admin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ SELECT
CAST((SELECT COUNT(*) FROM events WHERE deleted_at IS NULL) AS INTEGER) as event_count,
CAST((SELECT COUNT(DISTINCT name) FROM modules WHERE deleted_at IS NULL) AS INTEGER) as module_count,
CAST((SELECT COUNT(*) FROM programs WHERE deleted_at IS NULL) AS INTEGER) as program_count,
CAST((SELECT COUNT(*) FROM activities WHERE deleted_at IS NULL) AS INTEGER) as activity_count,
CAST((SELECT COUNT(*) FROM sessions) AS INTEGER) as session_count;
CAST((SELECT COUNT(*) FROM activities WHERE deleted_at IS NULL) AS INTEGER) as activity_count;

-- name: GetDailyUserGrowth :many
SELECT
Expand All @@ -27,15 +26,6 @@ WHERE created_at >= date('now', '-90 days') AND deleted_at IS NULL
GROUP BY date
ORDER BY date ASC;

-- name: GetDailySessionTrend :many
SELECT
date(created_at) as date,
COUNT(*) as count
FROM sessions
WHERE created_at >= date('now', '-90 days')
GROUP BY date
ORDER BY date ASC;

-- name: GetDailyExamGrowth :many
SELECT
date(created_at) as date,
Expand Down
9 changes: 0 additions & 9 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1849,12 +1849,6 @@ const docTemplate = `{
"$ref": "#/definitions/dto.ActivityResponse"
}
},
"session_trend": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.DashboardTrendItem"
}
},
"stats": {
"$ref": "#/definitions/dto.AdminStatsResponse"
},
Expand Down Expand Up @@ -1887,9 +1881,6 @@ const docTemplate = `{
"program_count": {
"type": "integer"
},
"session_count": {
"type": "integer"
},
"user_count": {
"type": "integer"
}
Expand Down
9 changes: 0 additions & 9 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,12 +1842,6 @@
"$ref": "#/definitions/dto.ActivityResponse"
}
},
"session_trend": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.DashboardTrendItem"
}
},
"stats": {
"$ref": "#/definitions/dto.AdminStatsResponse"
},
Expand Down Expand Up @@ -1880,9 +1874,6 @@
"program_count": {
"type": "integer"
},
"session_count": {
"type": "integer"
},
"user_count": {
"type": "integer"
}
Expand Down
6 changes: 0 additions & 6 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ definitions:
items:
$ref: '#/definitions/dto.ActivityResponse'
type: array
session_trend:
items:
$ref: '#/definitions/dto.DashboardTrendItem'
type: array
stats:
$ref: '#/definitions/dto.AdminStatsResponse'
user_growth_trend:
Expand All @@ -72,8 +68,6 @@ definitions:
type: integer
program_count:
type: integer
session_count:
type: integer
user_count:
type: integer
type: object
Expand Down
5 changes: 0 additions & 5 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ func Run() error {
IdleTimeout: 120 * time.Second,
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

go handler.StartSessionSweeper(ctx, querier, logger)

go func() {
logger.Info("Server starting", "port", cfg.HTTPPort, "version", Version)
if err := httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
Expand Down
2 changes: 0 additions & 2 deletions internal/api/dto/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ type AdminStatsResponse struct {
ModuleCount int64 `json:"module_count"`
ProgramCount int64 `json:"program_count"`
ActivityCount int64 `json:"activity_count"`
SessionCount int64 `json:"session_count"`
}

type DashboardTrendItem struct {
Expand All @@ -290,7 +289,6 @@ type AdminDashboardResponse struct {
ModuleGrowthTrend []DashboardTrendItem `json:"module_growth_trend"`
ProgramGrowthTrend []DashboardTrendItem `json:"program_growth_trend"`
ActivityTrend []DashboardTrendItem `json:"activity_trend"`
SessionTrend []DashboardTrendItem `json:"session_trend"`
ProgramDistribution []ProgramDistributionItem `json:"program_distribution"`
RecentActivities []ActivityResponse `json:"recent_activities"`
}
Expand Down
18 changes: 0 additions & 18 deletions internal/api/handler/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (s *Server) GetAdminStats(w http.ResponseWriter, r *http.Request) {
ModuleCount: stats.ModuleCount,
ProgramCount: stats.ProgramCount,
ActivityCount: stats.ActivityCount,
SessionCount: stats.SessionCount,
})
}

Expand All @@ -142,7 +141,6 @@ func (s *Server) GetAdminDashboard(w http.ResponseWriter, r *http.Request) {
discGrowth, _ := s.DB.GetDailyDiscussionGrowth(ctx)
moduleGrowth, _ := s.DB.GetDailyModuleGrowth(ctx)
programGrowth, _ := s.DB.GetDailyProgramGrowth(ctx)
sessionTrend, _ := s.DB.GetDailySessionTrend(ctx)
dist, _ := s.DB.GetUserProgramDistribution(ctx)
activities, _ := s.DB.ListAllActivities(ctx, database.ListAllActivitiesParams{
Limit: 10,
Expand Down Expand Up @@ -233,20 +231,6 @@ func (s *Server) GetAdminDashboard(w http.ResponseWriter, r *http.Request) {
}
}

sessionDto := make([]dto.DashboardTrendItem, len(sessionTrend))
for i, s := range sessionTrend {
dateStr := ""
if str, ok := s.Date.(string); ok {
dateStr = str
} else if s.Date != nil {
dateStr = fmt.Sprint(s.Date)
}
sessionDto[i] = dto.DashboardTrendItem{
Date: dateStr,
Count: s.Count,
}
}

distDto := make([]dto.ProgramDistributionItem, len(dist))
for i, d := range dist {
distDto[i] = dto.ProgramDistributionItem{
Expand Down Expand Up @@ -277,15 +261,13 @@ func (s *Server) GetAdminDashboard(w http.ResponseWriter, r *http.Request) {
ModuleCount: stats.ModuleCount,
ProgramCount: stats.ProgramCount,
ActivityCount: stats.ActivityCount,
SessionCount: stats.SessionCount,
},
UserGrowthTrend: growthDto,
ExamGrowthTrend: examDto,
DiscussionGrowthTrend: discDto,
ModuleGrowthTrend: moduleGrowthDto,
ProgramGrowthTrend: programGrowthDto,
ActivityTrend: trendDto,
SessionTrend: sessionDto,
ProgramDistribution: distDto,
RecentActivities: activitiesDto,
})
Expand Down
27 changes: 0 additions & 27 deletions internal/api/handler/sessions.go

This file was deleted.

43 changes: 1 addition & 42 deletions internal/database/admin.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion internal/database/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions website/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ const AdminDashboard: React.FC = () => {
}, []);

const growthData = data?.user_growth_trend?.map(item => Number(item.count) || 0) || [];

const sessionData = data?.session_trend?.map(item => Number(item.count) || 0) || [];
const sessionLabels = data?.session_trend?.map(item => item.date ? new Date(item.date).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit' }) : '') || [];
const growthLabels = data?.user_growth_trend?.map(item => item.date ? new Date(item.date).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit' }) : '') || [];

const examData = data?.exam_growth_trend?.map(item => Number(item.count) || 0) || [];
const discData = data?.discussion_growth_trend?.map(item => Number(item.count) || 0) || [];
Expand Down Expand Up @@ -117,12 +115,12 @@ const AdminDashboard: React.FC = () => {
minWidth: 0
}}>
<UserGrowthChart
title="Sitzungen"
value={data?.stats?.session_count || 0}
title="Benutzerwachstum"
value={data?.stats?.user_count || 0}
trend="up"
caption="Sitzungen pro Tag in den letzten 90 Tagen"
data={sessionData}
labels={sessionLabels}
caption="Neue Benutzer pro Tag in den letzten 90 Tagen"
data={growthData}
labels={growthLabels}
loading={loading}
/>
</Box>
Expand Down
22 changes: 11 additions & 11 deletions website/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@mui/material": "^7.3.8",
"@mui/material-nextjs": "^7.3.8",
"@mui/x-charts": "^8.27.0",
"@mui/x-data-grid": "^8.27.1",
"@mui/x-data-grid": "^8.27.3",
"jose": "^6.1.3",
"next": "^16.1.6",
"next-auth": "^5.0.0-beta.30",
Expand All @@ -36,7 +36,7 @@
"@types/react-dom": "19.2.3",
"@typescript-eslint/eslint-plugin": "8.56.1",
"@typescript-eslint/parser": "8.56.1",
"@typescript/native-preview": "^7.0.0-dev.20260224.1",
"@typescript/native-preview": "^7.0.0-dev.20260225.1",
"eslint": "10.0.2",
"eslint-config-next": "^16.1.6",
"eslint-plugin-react-hooks": "7.0.1",
Expand Down
Loading