Koha/t
Jonathan Druart 63a1adff90 Bug 18066: Hea V2
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>
2017-03-23 00:10:46 +00:00
..
Acquisition
Biblio Bug 17641: Fix t/Biblio/Isbd.t 2016-11-16 14:02:30 +00:00
Budgets
Circulation Bug 17557: Koha::Patrons - Move GetAge to ->set_age (and remove SetAge) 2016-12-16 11:57:38 +00:00
db_dependent Bug 18066: Hea V2 2017-03-23 00:10:46 +00:00
edi_testfiles
External Bug 16636 [QA Followup] - Move tests to t/External 2016-06-10 18:02:14 +00:00
Koha Bug 17302: [Follow-up] Make Normalize.pm undef-resistent 2016-09-25 14:04:54 +00:00
lib Bug 17726: biblioitems.marc has been removed 2017-01-20 13:43:18 +00:00
Members Bug 15690: Hardcoded 16 is uncool 2016-11-14 11:28:43 +00:00
Number Bug 16768: Add tests for Swiss number format 2016-06-24 14:00:03 +00:00
Search Bug 10807: Add an authority search history for the OPAC 2014-05-05 02:32:27 +00:00
Serials Bug 16289: Refactore code and add tests 2016-06-10 18:09:48 +00:00
SIP Bug 15006: Centralize timeout logic and allow zero client timeout 2016-07-15 14:11:05 +00:00
00-checkdatabase-version.t
00-deprecated.t
00-load.t Bug 18243: 16034 follow-up: Conditionally test Koha::ExternalContent::* modules loading 2017-03-20 15:28:35 +00:00
00-merge-conflict-markers.t
00-testcritic.t
00-valid-xml.t Bug 16608 - Add xsd extension to t/00-valid-xml.t 2016-06-10 17:40:55 +00:00
Auth_with_shibboleth.t Bug 17681: Exiisting typos might thow some feees when recieved 2016-12-16 11:29:33 +00:00
AuthoritiesMarc_MARC21.t
AuthoritiesMarc_UNIMARC.t
AuthUtils.t
Barcodes_annual.t
Barcodes_EAN13.t
Barcodes_hbyymmincr.t
Barcodes_incremental.t
Biblio.t
Biblio2.t Bug 16556 - KohaToMarcMapped columns sharing same field with biblio(item)number are removed. 2016-09-15 13:42:35 +00:00
Bookseller.t Total Test Overhaul! Most of these were stubs, and still are. 2007-10-18 16:26:44 -05:00
Boolean.t
Breeding.t Bug 13279: t/Breeding.t shouldn't depend on the DB 2014-11-20 09:39:53 -03:00
Budgets.t C4::Bookfund no longer exists, removing the test 2009-12-20 14:31:37 +01:00
Cache.t Bug 16769: Uniformise calls to Koha::Cache->set_in_cache 2016-10-10 17:03:54 +00:00
Calendar.t Bug 17189: Replace occurrences of 'use Koha::Cache' 2016-09-08 10:24:47 +00:00
Charset.t Bug 14112: Silence warnings in t/Charset.t 2015-05-27 14:32:41 -03:00
Circulation_barcodedecode.t
ClassSortRoutine.t
ClassSortRoutine_Dewey.t
ClassSortRoutine_Generic.t
ClassSortRoutine_LCC.t
ClassSource.t Bug 5327: Add basic unit tests to some C4 modules 2010-10-30 20:12:53 +13:00
Context.t
Contract.t
Creators.t Bug 16622: some tests triggered by prove t fail for unset KOHA_CONF 2016-08-05 06:09:58 +00:00
DateUtils.t Bug 17476: Add a way to bypass dt_from_string processing time for slow servers 2016-11-07 16:36:05 +00:00
Debug.t
dummy.t Total Test Overhaul! Most of these were stubs, and still are. 2007-10-18 16:26:44 -05:00
Edifact.t Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00
EdiInvoice.t
Ediorder.t Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00
Ediordrsp.t
Form_MessagingPreferences.t
Heading.t
Images.t Bug 15150: Make t/ tests skip if Test::DBIx::Class absent 2015-11-06 12:25:27 -03:00
ImportBatch.t Bug 10407: Add two subtests to t/ImportBatch.t 2016-09-02 16:00:13 +00:00
Installer_PerlDependencies.t
Installer_PerlModules.t Bug 17990: Refactor Perl module versions check 2017-02-17 12:13:44 +00:00
Installer_pm.t Bug 17990: Refactor Perl module versions check 2017-02-17 12:13:44 +00:00
ItemCirculationAlertPreference.t
Koha.t Bug 14629 - [QA Followup] Pass invalid ISSN through GetVariationsOfISSN 2016-10-28 11:58:14 +00:00
Koha_Email.t Bug 13172 t/Koha_Email.t was database dependent 2014-10-31 12:10:32 -03:00
Koha_ExternalContent_OverDrive.t Bug 18243: 16034 follow-up: better handling of absence of WebService::ILS::OverDrive::Patron at testing 2017-03-20 15:28:35 +00:00
Koha_MetadataRecord.t
Koha_Template_Plugin_Cache.t
Koha_Template_Plugin_Koha.t Bug 18222 - Fix tests broken by Buug 18026 2017-03-20 15:33:45 +00:00
Koha_Util_FrameworkPlugin.t Bug 13437: Preliminary changes for marc21 plugins field 008 2015-06-10 12:51:26 -03:00
Koha_Util_MARC.t
Labels.t Bug 9978: (followup) Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:43 -03:00
Labels_split_ccn.t
Labels_split_ddcn.t Bug 9978: (followup) Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:43 -03:00
Labels_split_lccn.t
Languages.t Bug 16675: fix breakage of t/Languages.t 2016-06-10 17:03:10 +00:00
Letters.t
Log.t
Logger.t
Matcher.t Bug 17318: Unit tests 2016-10-21 16:16:33 +00:00
Members_Attributes.t Bug 12267: Remove borrower_attributes.password 2016-04-22 23:08:32 +00:00
Members_AttributeTypes.t
Members_Messaging.t Bug 5327: More basic unit tests for C4 modules 2010-11-01 15:35:50 +13:00
Message.t
NorwegianPatronDB.t
OpenLibrarySearch.t Bug 16649: Make OpenLibrarySearch test pass even if launches offline 2016-06-10 17:05:03 +00:00
Output.t Bug 11944: use CGI( -utf8 ) everywhere 2015-01-13 13:07:21 -03:00
Output_JSONStream.t
Overdues.t Bug 13283: t/Overdues.t shouldn't depend on the DB 2014-11-20 09:37:39 -03:00
Patron.t Bug 17425 [QA Followup] - Remove superfluous tests 2016-10-21 18:15:50 +00:00
Patroncards.t Bug 5327: Add basic unit tests to some C4 modules 2010-10-30 20:12:53 +13:00
Patroncards_Batch.t
Patroncards_Layout.t
Patroncards_Lib.t
Patroncards_Patroncard.t
Patroncards_Profile.t
Patroncards_Template.t
perlcriticrc Bug 15258: Prevent unused declared variables 2015-12-30 17:24:30 -07:00
Prices.t Bug 13726: Make Koha::Acq::Bookseller using Koha::Object 2016-12-30 11:54:32 +00:00
Print.t
QueryParser.t
RecordProcessor.t
Ris.t Bug 16668: Fix t/Ris.t tests 2016-06-10 16:59:20 +00:00
RotatingCollections.t
Scheduler.t
Scrubber.t Bug 14116: Silence noisy output for t/Scrubber. 2015-06-01 14:10:56 -03:00
Search.t
Search_PazPar2.t
SimpleMARC.t
smolder_smoke_signal Bug 2524: Adding script to submit test reports to smolder server 2008-08-18 07:16:35 -05:00
SMS.t
SocialData.t Bug 15150: Make t/ tests skip if Test::DBIx::Class absent 2015-11-06 12:25:27 -03:00
Stats.t
SuggestionEngine.t
SuggestionEngine_AuthorityFile.t
TmplToken.t
Token.t Bug 17110: Add unit test for MaxAge parameter in Token.t 2016-09-09 13:40:41 +00:00
XSLT.t Bug 18089: Remove warnings from tests using DBIx::Class fixtures 2017-02-14 14:07:02 +00:00