From 259be09c7e70e8858ae2317ff50c3bb064953d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Freyd?= Date: Mon, 27 Nov 2017 09:02:37 -0500 Subject: [PATCH] Add more statistics at the instance level (#661) The DB has changed a lot in the last months. If we want to be able to track how people are using the application, we need to add more statistics at the instance level. This shouldn't be too hard on the DB to calculate those every night at midnight. --- CHANGELOG | 2 +- app/Console/Commands/CalculateStatistics.php | 16 +++++++++ .../2017_11_27_083043_add_more_statistics.php | 34 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2017_11_27_083043_add_more_statistics.php diff --git a/CHANGELOG b/CHANGELOG index ac11075fbe2..7eea1d7d775 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ UNRELEASED CHANGES: -* Add the ability to set as many contact fields to a contact as needed +* Add more usage statistics to reflect latest changes in the DB. RELEASED VERSIONS: diff --git a/app/Console/Commands/CalculateStatistics.php b/app/Console/Commands/CalculateStatistics.php index 1abcecc14c7..062016f997f 100644 --- a/app/Console/Commands/CalculateStatistics.php +++ b/app/Console/Commands/CalculateStatistics.php @@ -58,6 +58,22 @@ public function handle() $statistic->number_of_accounts_with_more_than_one_user = $number_of_accounts_with_more_than_one_user; $statistic->number_of_import_jobs = DB::table('import_jobs')->count(); $statistic->number_of_tags = DB::table('tags')->count(); + $statistic->number_of_activities = DB::table('activities')->count(); + $statistic->number_of_addresses = DB::table('addresses')->count(); + $statistic->number_of_api_calls = DB::table('api_usage')->count(); + $statistic->number_of_calls = DB::table('calls')->count(); + $statistic->number_of_contact_fields = DB::table('contact_fields')->count(); + $statistic->number_of_contact_field_types = DB::table('contact_field_types')->count(); + $statistic->number_of_debts = DB::table('debts')->count(); + $statistic->number_of_entries = DB::table('entries')->count(); + $statistic->number_of_gifts = DB::table('gifts')->count(); + $statistic->number_of_oauth_access_tokens = DB::table('oauth_access_tokens')->count(); + $statistic->number_of_oauth_clients = DB::table('oauth_clients')->count(); + $statistic->number_of_offsprings = DB::table('offsprings')->count(); + $statistic->number_of_progenitors = DB::table('progenitors')->count(); + $statistic->number_of_relationships = DB::table('relationships')->count(); + $statistic->number_of_subscriptions = DB::table('subscriptions')->count(); + $statistic->save(); } } diff --git a/database/migrations/2017_11_27_083043_add_more_statistics.php b/database/migrations/2017_11_27_083043_add_more_statistics.php new file mode 100644 index 00000000000..8d34f20999c --- /dev/null +++ b/database/migrations/2017_11_27_083043_add_more_statistics.php @@ -0,0 +1,34 @@ +integer('number_of_activities')->after('number_of_kids'); + $table->integer('number_of_addresses')->after('number_of_activities'); + $table->integer('number_of_api_calls')->after('number_of_addresses'); + $table->integer('number_of_calls')->after('number_of_api_calls'); + $table->integer('number_of_contact_fields')->after('number_of_calls'); + $table->integer('number_of_contact_field_types')->after('number_of_contact_fields'); + $table->integer('number_of_debts')->after('number_of_contact_field_types'); + $table->integer('number_of_entries')->after('number_of_debts'); + $table->integer('number_of_gifts')->after('number_of_entries'); + $table->integer('number_of_oauth_access_tokens')->after('number_of_notes'); + $table->integer('number_of_oauth_clients')->after('number_of_oauth_access_tokens'); + $table->integer('number_of_offsprings')->after('number_of_oauth_clients'); + $table->integer('number_of_progenitors')->after('number_of_offsprings'); + $table->integer('number_of_relationships')->after('number_of_progenitors'); + $table->integer('number_of_subscriptions')->after('number_of_relationships'); + }); + } +}