Skip to content

Commit

Permalink
Add more statistics at the instance level (#661)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
djaiss authored Nov 27, 2017
1 parent a9a61d7 commit 259be09
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
16 changes: 16 additions & 0 deletions app/Console/Commands/CalculateStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
34 changes: 34 additions & 0 deletions database/migrations/2017_11_27_083043_add_more_statistics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddMoreStatistics extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('statistics', function (Blueprint $table) {
$table->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');
});
}
}

0 comments on commit 259be09

Please sign in to comment.