Bugzilla – Attachment 181708 Details for
Bug 37901
Add ILL pseudonymization
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37901: Add Tests
Bug-37901-Add-Tests.patch (text/plain), 4.18 KB, created by
Pedro Amorim
on 2025-04-30 08:34:30 UTC
(
hide
)
Description:
Bug 37901: Add Tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-04-30 08:34:30 UTC
Size:
4.18 KB
patch
obsolete
>From 02a19c9e8fbea0a93bec67047772230869866817 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Wed, 16 Apr 2025 12:19:16 +0000 >Subject: [PATCH] Bug 37901: Add Tests > >Example reports that can be written for ILL pseudonymized data: > >--Total of requests of a given request type (article)-- > >SELECT > COUNT(*) AS count >FROM > pseudonymized_transactions pt >WHERE > EXISTS ( > SELECT 1 > FROM pseudonymized_metadata_values pmv > WHERE pmv.transaction_id = pt.id > AND pmv.key = 'type' > AND pmv.value = 'article' > ); > >--Add backend info to listing-- > >SELECT > pt.*, > (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE pmv.transaction_id = pt.id AND pmv.key = 'type') AS type, > (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE pmv.transaction_id = pt.id AND pmv.key = 'backend') AS backend >FROM > pseudonymized_transactions pt; > >--List all pseudonymized transactions and respective metadata values-- > >SELECT > pt.*, > table1.metadata AS borrower_attributes, > table2.metadata AS illrequestattributes >FROM > pseudonymized_transactions pt > LEFT JOIN ( > SELECT > transaction_id, > GROUP_CONCAT(DISTINCT CONCAT(`key`, ':', value)) AS metadata > FROM > pseudonymized_metadata_values > WHERE tablename = 'borrower_attributes' > GROUP BY > transaction_id > ) table1 ON pt.id = table1.transaction_id > LEFT JOIN ( > SELECT > transaction_id, > GROUP_CONCAT(DISTINCT CONCAT(`key`, ':', value)) AS metadata > FROM > pseudonymized_metadata_values > WHERE tablename = 'illrequestattributes' > GROUP BY > transaction_id > ) table2 ON pt.id = table2.transaction_id; > >--ILL specific pseudonymized transactions report-- > >SELECT > pt.hashed_borrowernumber as 'borrower',pt.transaction_type as 'Transaction type', pt.datetime as 'Datetime', pt.branchcode as 'Patron branchcode', pt.categorycode as 'Patron category', > (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE pmv.transaction_id = pt.id AND pmv.key = 'type') AS type, > (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE pmv.transaction_id = pt.id AND pmv.key = 'backend') AS backend >FROM > pseudonymized_transactions pt > >Sponsored-by: UKHSA - UK Health Security Agency > >Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk> >--- > t/db_dependent/Koha/Pseudonymization.t | 34 +++++++++++++++++++++++++- > 1 file changed, 33 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t >index c61d7f3e4f6..50a4b99041b 100755 >--- a/t/db_dependent/Koha/Pseudonymization.t >+++ b/t/db_dependent/Koha/Pseudonymization.t >@@ -148,7 +148,7 @@ subtest 'Koha::Anonymized::Transactions tests' => sub { > > subtest 'PseudonymizedMetadataValues tests' => sub { > >- plan tests => 5; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -275,5 +275,37 @@ subtest 'PseudonymizedMetadataValues tests' => sub { > 'The id of the 2nd pseudonymized transaction should be different' > ); > >+ my $ill_request = $builder->build_sample_ill_request(); >+ $builder->build( >+ { >+ source => 'Illrequestattribute', >+ value => { illrequest_id => $ill_request->illrequest_id, type => 'type', value => 'book' } >+ } >+ ); >+ >+ my $ill_request_statistic = Koha::Statistic->new( >+ { >+ type => 'illreq_created', >+ branch => $library->branchcode, >+ itemnumber => undef, >+ borrowernumber => $patron->borrowernumber, >+ itemtype => undef, >+ location => undef, >+ illrequest_id => $ill_request->illrequest_id, >+ ccode => undef, >+ } >+ ); >+ >+ my $p2 = Koha::PseudonymizedTransaction->create_from_statistic($ill_request_statistic)->store; >+ >+ my $ill_metadata_values = >+ Koha::Database->new->schema->resultset('PseudonymizedMetadataValue') >+ ->search( { transaction_id => $p2->id, tablename => 'illrequestattributes' }, { order_by => 'value' } ); >+ >+ my $ill_metadata_value = $ill_metadata_values->next; >+ >+ is( $ill_metadata_value->key, 'type' ); >+ is( $ill_metadata_value->value, 'book' ); >+ > $schema->storage->txn_rollback; > }; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37901
:
178356
|
178956
|
178957
|
178958
|
178959
|
178960
|
178961
|
178962
|
178963
|
178964
|
178965
|
178966
|
178967
|
178968
|
178980
|
178981
|
178982
|
178983
|
178984
|
178985
|
178986
|
178987
|
178988
|
178989
|
178990
|
178991
|
178992
|
181008
|
181009
|
181010
|
181011
|
181012
|
181013
|
181014
|
181015
|
181016
|
181017
|
181018
|
181019
|
181020
|
181696
|
181697
|
181698
|
181699
|
181700
|
181701
|
181702
|
181703
|
181704
|
181705
|
181706
|
181707
| 181708