From 13d17f13e700229a847a4199c481886944b7c967 Mon Sep 17 00:00:00 2001
From: nar20 <nar20@inf.ufpr.br>
Date: Wed, 24 Apr 2024 09:26:13 -0300
Subject: [PATCH] [add] unique user count to route statistics

Signed-off-by: nar20 <nar20@inf.ufpr.br>
---
 app/controllers/v1/statistics_controller.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/app/controllers/v1/statistics_controller.rb b/app/controllers/v1/statistics_controller.rb
index 275499f3d..16ae3e791 100644
--- a/app/controllers/v1/statistics_controller.rb
+++ b/app/controllers/v1/statistics_controller.rb
@@ -21,7 +21,7 @@ class V1::StatisticsController < ApplicationController
   # GET v1/statistics
   # GET v1/statistics.json
   def index
-    statistics = { count: count_learning_objects, month_publications: month_publications, month_downloads: month_downloads }
+    statistics = { count: count_learning_objects, month_publications: month_publications, month_downloads: month_downloads,  unique_users: unique_users}
     render json: statistics
   end
 
@@ -38,4 +38,8 @@ class V1::StatisticsController < ApplicationController
   def month_downloads
     Download.where('extract (month from created_at) = ? and extract (year from created_at) = ?', Time.current.month, Time.current.year).count
   end
+
+  def unique_users
+    User.distinct.count
+  end
 end
-- 
GitLab