@@ -13,6 +13,9 @@ class AnalyticsController extends Controller
13
13
{
14
14
public function index ()
15
15
{
16
+ $ this ->authorize ('update ' , AccessControl::class);
17
+
18
+ $ cacheName = 'AnalyticsController::index ' ;
16
19
17
20
$ roundsInThePastYear = cache ()->remember ('rounds_in_the_past_year ' , 86400 , function () {
18
21
return Round::where ('created_at ' , '>= ' , now ()->subYear ())
@@ -21,7 +24,8 @@ public function index()
21
24
->get (['id ' , 'uuid ' , 'name ' ]);
22
25
});
23
26
24
- $ stats = cache ()->remember ('analytics_stats ' , 86400 , function () use ($ roundsInThePastYear ) {
27
+
28
+ $ stats = cache ()->remember ($ cacheName , 86400 , function () use ($ roundsInThePastYear ) {
25
29
$ stats = [
26
30
'rounds ' => 0 ,
27
31
'applications ' => 0 ,
@@ -61,10 +65,17 @@ public function index()
61
65
return $ stats ;
62
66
});
63
67
68
+ // Get a list of rounds that have human evaluators, and pull out the round, together with the humans
69
+ $ roundsEvaluatedByHumans = Round::whereHas ('evaluationAnswers ' , function ($ query ) {
70
+ $ query ->with ('user ' );
71
+ })->with (['evaluationAnswers ' => function ($ query ) {
72
+ $ query ->with ('user ' )->select ('user_id ' , 'round_id ' )->groupBy ('user_id ' , 'round_id ' );
73
+ }])->get (['id ' , 'uuid ' , 'chain_id ' , 'name ' ]);
64
74
65
75
return Inertia::render ('Analytics/Index ' , [
66
76
'roundsInThePastYear ' => $ roundsInThePastYear ,
67
77
'stats ' => $ stats ,
78
+ 'roundsEvaluatedByHumans ' => $ roundsEvaluatedByHumans ,
68
79
]);
69
80
}
70
81
}
0 commit comments