Bug 33568: Restore analytics

FIXME We cannot have the usual _count/+count pattern for the REST API, I
think it's acceptable

FIXME We lost the sort on this column, not a big deal IMO

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2023-05-24 15:19:43 +02:00 committed by Katrin Fischer
parent 09934c0160
commit cf9fb86a01
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
4 changed files with 28 additions and 5 deletions

View file

@ -2366,6 +2366,11 @@ sub is_denied_renewal {
return 0;
}
sub analytics_count {
my ($self) = @_;
return C4::Items::GetAnalyticsCount($self->itemnumber);
}
=head3 strings_map
Returns a map of column name to string representations including the string,

View file

@ -288,6 +288,10 @@ properties:
type:
- object
- "null"
analytics_count:
type:
- integer
- "null"
_strings:
type:
- object

View file

@ -441,6 +441,7 @@
- bundle_items_lost+count
- bundle_items_not_lost+count
- course_item.course_reserves.course
- analytics_count
- cover_image_ids
- item_group_item.item_group.description
- serialitem.serial

View file

@ -2197,6 +2197,10 @@
// For host records
embed.push('biblio.title');
[% IF analyze %]
embed.push('analytics_count');
[% END %]
let items_table_settings = {
holdings: [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %],
otherholdings: [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json') | $raw %],
@ -2601,13 +2605,22 @@
return '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=%s">%s</a>'.format(row.biblio_id, row.biblio.title);
}
},
[% IF ( analyze ) %]
[% IF analyze %]
{
data: "",
searchable: false, // FIXME
orderable: true,
data: "analytics_count",
searchable: false,
orderable: false,
render: function (data, type, row, meta) {
return ""; // FIXME Display analytic count + link
if (row.analytics_count == 0) return ""
return '<a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=%s">%s analytics</a>'.format(row.item_id, row.analytics_count);
}
},
{
data: "analytics_count", // create analytics link
searchable: false,
orderable: false,
render: function (data, type, row, meta) {
return '<a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=%s&amp;hostitemnumber=%s">Create analytics</a>'.format(row.biblio_id, row.item_id);
}
},
[% END %]