Jonathan Druart
63a1adff90
This patch is the Koha part of the Hea v2 project. You can find the (testing) code for the server at hea-ws - https://github.com/joubu/hea-ws/commits/v2 hea-app - https://github.com/joubu/hea-app/commits/v2 They contain the different pull requests made over the last 6 months. More information on Hea at https://wiki.koha-community.org/wiki/KohaUsageStat_RFC The goal of this commit message is to provide an overview of what could be a new version of Hea. Prior to these changes, the Hea database was filled with 1 line per Koha installation. System preferences were filled by the libraries and a cronjob (share_usage_with_koha_community.pl) collected these values to send them to a webservice (hea-ws/upload.pl). With the need to collect more data we would want to collect data at the library level (branch) and not at the installation level. For instance the geolocation, the url or the country can be different from one library to another, even if managed from the same Koha installation. The Hea DB has been upgraded to reflect that change (see hea-app/sql/schema.sql). The hidden goal of this patch is to make Hea sexier and explain better to libraries how it can be useful to share their information with the Koha community. I guess the main problem is the lack of communication and explanations about what we are doing we these data. To fill this gap I'd like to (TODO) 1. Communicate on the ML about this new version of Hea (once it got pushed and backported) 2. Link the Privacy_Policy.md from the Hea interface 3. Get help from a native English speaker to add popup/help/info/whatever on "Home › Administration › Usage statistics", to clearly explain what happens (and what will not happen!) when an option or another is set. You can find screenshot of this whole enhancement on bug 18066, comment 2. What this patch does: - Create a new branches.geolocation DB field - Add 3 new sysprefs: * UsageStatsGeolocation * UsageStatsLibrariesInfo * UsageStatsPublicID - Integrate the Leaflet JS library to get a fancy map to pick geolocations How does it works: On the new administration page where statistics to share are configured, there are several new things. It is now possible to share information either per Koha installation or libraries. If UsageStatsLibrariesInfo is set, the info at library level (url, name, country, geolocation) will be sent to the Hea webservice. If it is not set, you can decide to fill UsageStatsLibraryUrl, UsageStatsLibraryName, UsageStatsCountry, UsageStatsGeolocation to share these information. Note that even if the data are retrieved at installation level, it's better to fill the prefs as well: On the Hea website the different libraries defined for a given Koha installation could be displayed on the same page. This page is a public page which will be attributed to every installation (with the pref UsageStatsPublicID). On this page all the info available publicly will be displayed. TODO later: - Add a button on the administration page to delete the info shared publicly. It will be easy to show that the info are no longer displayed on the public page. - Add an icon per Koha installation to get a better "public page" - Any suggestions? Test plan: We will need to test hea-ws, hea-app and the Koha-side code to test the whole enhancement. 1/ To start, clone the hea-ws and hea-app project and checkout the 'master' branch (*not* 'v2') 2/ Create the hea database and user CREATE DATABASE hea CREATE USER 'hea'@'localhost' IDENTIFIED BY 'hea'; GRANT ALL PRIVILEGES ON hea.* TO 'hea'@'localhost'; FLUSH PRIVILEGES; 3/ Fill the DB with some data mysql hea < hea-app/sql/schema.sql mysql hea < hea-app/sql/sql/mock-data.sql 4/ Checkout the 'v2' branch for both hea-ws and hea-app 5/ Execute the upgrade DB script % cd hea-app % perl -p -i -e 's/REPLACE_ME/hea/' sql/upgrade.pl # Fill the DB info % perl sql/upgrade.pl Now the DB is using the v2 structure. That means we have 1 installation row per library previously defined. 1 library row has also been created. 5/ Configure hea-ws % echo '192.168.50.1 hea.koha-community.org' >> /etc/hosts <VirtualHost *:80> DocumentRoot "/path/to/hea-ws" ServerName "hea.koha-community.org" <Directory "/"> Options +ExecCGI Require all granted AddHandler cgi-script .pl </Directory> </VirtualHost> And enable it with a2ensite, then restart apache. The copy the database.yml.sample to database.yml and edit it to fill the DB info. 6/ Launch the hea-app % cd hea-app % edit README.md # to install the missing modules % cp environments/config.yml environments/development.yml % edit environments/development.yml # to fill the DB info % perl bin/app.pl Then hit localhost:3000 You should see a local version of Hea with sample data 7/ Back to Koha side A. We will test that the webservice still works with previous version of Koha (without v2) a. Do not configure Hea % perl misc/cronjobs/share_usage_with_koha_community.pl -f -v Then hit localhost:3000 => Nothing added b. Configure Hea on admin/usage_statistics.pl perl misc/cronjobs/share_usage_with_koha_community.pl -f -v => New library added c. Modify the Hea configuration perl misc/cronjobs/share_usage_with_koha_community.pl -f -v => Info are modified B. Not we will test that it works with the new version (much more fun ;)) % git checkout hea-v2 # koha a. Configure Hea using /admin/usage_statistics.pl perl misc/cronjobs/share_usage_with_koha_community.pl -f -v => Check the result on localhost:3000 b. Share libraries's info perl misc/cronjobs/share_usage_with_koha_community.pl -f -v c. Continue to play a bit and share the info. Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
123 lines
3.2 KiB
Perl
Executable file
123 lines
3.2 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use Modern::Perl;
|
|
|
|
use Pod::Usage;
|
|
use Getopt::Long;
|
|
|
|
use C4::Context;
|
|
use C4::UsageStats;
|
|
use C4::Log;
|
|
use POSIX qw(strftime);
|
|
|
|
my ( $help, $verbose, $force, $quiet );
|
|
GetOptions(
|
|
'h|help' => \$help,
|
|
'v|verbose' => \$verbose,
|
|
'f|force' => \$force,
|
|
'q|quiet' => \$quiet,
|
|
) || pod2usage(1);
|
|
|
|
if ($help) {
|
|
pod2usage(0);
|
|
}
|
|
|
|
unless ( C4::Context->preference('UsageStats') ) {
|
|
$quiet && exit;
|
|
pod2usage(
|
|
q|
|
|
The UsageStats system preference is not set.
|
|
If your library wants to share their usage statistics with the Koha community, you have to switch on this system preference
|
|
|
|
Setting the quiet flag will silence this message.
|
|
|
|
|
);
|
|
exit 1;
|
|
}
|
|
|
|
cronlogaction();
|
|
|
|
my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() );
|
|
|
|
if ($need_update) {
|
|
say "Data need to be updated" if $verbose;
|
|
my $report = C4::UsageStats::BuildReport();
|
|
C4::UsageStats::ReportToCommunity($report);
|
|
C4::Context->set_preference( 'UsageStatsLastUpdateTime',
|
|
strftime( "%s", localtime ) );
|
|
}
|
|
elsif ($verbose) {
|
|
say "Data don't need to be updated";
|
|
}
|
|
|
|
=head1 NAME
|
|
|
|
share_usage_with_koha_community.pl - Share your library's usage with the Koha community
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
share_usage_with_koha_community.pl [-h|--help] [-v|--verbose] [-f|--force] [-q|--quiet]
|
|
|
|
If the UsageStats system preference is set, you can launch this script to share your usage data
|
|
anonymously with the Koha community.
|
|
|
|
Collecting Koha usage statistics will help developers to know how Koha is used across the world.
|
|
|
|
This script will send the usage data for the bibliographic and authority records, checkouts, holds, orders,
|
|
and subscriptions.
|
|
|
|
Only the total number is retrieved. In no case will private data be shared!
|
|
|
|
In order to know which parts of Koha modules are used, this script will collect some system preference values.
|
|
|
|
If you want to tell us who you are, you can fill the UsageStatsLibraryName system preference with your library name, UsageStatsLibraryUrl, UsageStatsLibraryType and/or UsageStatsCountry, UsageStatsLibrariesInfo.
|
|
|
|
All these data will be analyzed on the http://hea.koha-community.org Koha community website.
|
|
|
|
IMPORTANT : please do NOT run the cron on the 1st, but on another day. The idea is to avoid all
|
|
Koha libraries sending their data at the same time ! So choose any day between 1 and 28 !
|
|
|
|
=head1 OPTIONS
|
|
|
|
=over
|
|
|
|
=item B<-h|--help>
|
|
|
|
Print a brief help message
|
|
|
|
=item B<-v|--verbose>
|
|
|
|
Verbose mode
|
|
|
|
=item B<-f|--force>
|
|
|
|
Force the update
|
|
|
|
=item B<-q|--quiet>
|
|
|
|
Do not emit "The UsageStats system preference is not set" message
|
|
|
|
=back
|
|
|
|
=head1 AUTHOR
|
|
|
|
Alex Arnaud <alex.arnaud@biblibre.com>
|
|
|
|
Jonathan Druart <jonathan.druart@biblibre.com>
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
Copyright 2014 BibLibre
|
|
|
|
=head1 LICENSE
|
|
|
|
This file is part of Koha.
|
|
|
|
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
|
|
Foundation; either version 3 of the License, or (at your option) any later version.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with Koha; if not, write to the Free Software Foundation, Inc.,
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
=cut
|