"Last Few Circulations" total circulation count does not include aged circulations

Bug #1203734 reported by Chris Sharp
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Medium
Unassigned
2.6
Fix Released
Medium
Unassigned
2.7
Fix Released
Undecided
Unassigned

Bug Description

The "Show Last Few Circulations" interface, available from several access points with the staff client, has a "Total Circs" column in its display that does not count archived circulations.

Following the thread from the interface's XUL file:

Open-ILS/xul/staff_client/server/cat/copy_summary.xul: 'render' : 'v = obj.network.simple_request("FM_CIRC_COUNT_RETRIEVE_VIA_COPY",[ my.acp.id() ]).total.count; v;'

Open-ILS/xul/staff_client/chrome/content/main/constants.js: 'FM_CIRC_COUNT_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.count' },

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm:

__PACKAGE__->register_method(
        method => "circ_count",
        api_name => "open-ils.circ.circulation.count",
        notes => q/
                Returns the number of times the item has circulated
                @param copyid The copy to check
        /);

sub circ_count {
        my( $self, $client, $copyid, $range ) = @_;
        my $e = OpenILS::Utils::Editor->new;
        return $e->request('open-ils.storage.asset.copy.circ_count', $copyid, $range);
}

Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm:

sub circ_count {
        my $self = shift;
        my $client = shift;
        my $copy = shift;
        my $granularity = shift;

        my $c_table = action::circulation->table;

        if (lc($granularity) eq 'year') {
                $granularity = ", to_char(xact_start, 'YYYY') as when";
        } elsif (lc($granularity) eq 'month') {
                $granularity = ", to_char(xact_start, 'YYYY-MM') as when";
        } elsif (lc($granularity) eq 'day') {
                $granularity = ", to_char(xact_start, 'YYYY-MM-DD') as when";
        } else {
                $granularity = ", 'total' as when";
        }

        my $SQL = <<" SQL";
                SELECT COUNT(*) as count $granularity
                  FROM $c_table
                  WHERE target_copy = ?
        SQL

        if ($granularity !~ /total/o) {
                $SQL .= ' GROUP BY 2 ORDER BY 2';
        }

        $log->debug("Circ count SQL [$SQL]", DEBUG);

        return action::circulation->db_Main->selectall_hashref($SQL, 'when', {}, $copy);
}
__PACKAGE__->register_method(
        method => 'circ_count',
        api_name => 'open-ils.storage.asset.copy.circ_count',
        argc => 1,
);

"my $c_table = action::circulation->table;" - only includes "action.circulation"

Evergreen 2.3.6
OpenSRF 2.1.2
PostgreSQL 9.1.9
Ubuntu 12.04

tags: added: bitesize staffclient
Revision history for this message
Chris Sharp (chrissharp123) wrote :

My attempt at a fix:

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/csharp/fix_show_last_few_circulations_circ_count

Dan Wells mentioned in IRC that we should try and leverage extend_reporter.full_circ_count here, which includes any entries to extend_reporter.legacy_circ_count in the totals. My fix here doesn't do that yet.

Revision history for this message
Ben Shum (bshum) wrote :

Assigning initial target of 2.5.1 (next bug fix release for 2.5 series). Do we want backport targets for other series?

Changed in evergreen:
importance: Undecided → Medium
status: New → Confirmed
milestone: none → 2.5.1
Revision history for this message
Ben Shum (bshum) wrote :

Also, ready for "pullrequest" tagging?

Ben Shum (bshum)
Changed in evergreen:
milestone: 2.5.1 → 2.5.2
Dan Wells (dbw2)
tags: added: pullrequest
Changed in evergreen:
milestone: 2.5.2 → 2.6.0-alpha1
Dan Wells (dbw2)
Changed in evergreen:
milestone: 2.6.0-alpha1 → 2.6.0-beta1
Dan Wells (dbw2)
Changed in evergreen:
milestone: 2.6.0-beta1 → 2.6.0-rc1
Changed in evergreen:
milestone: 2.6.0-rc1 → 2.next
Revision history for this message
Bill Erickson (berick) wrote :

I've pushed an alternate branch which includes legacy circs and collects data via cstore instead of storage.

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1203734-last-few-circs-via-cstore

With the move to cstore, the storage call is no longer used, so I've removed it as well for the sake of cleanup.

--
Note, the storage call supported additional "granularity" options which were never used, so I didn't bother porting them to the cstore version. If there is 3rd-party code out there which does use it, we may have to reconsider.
--

My code sums rows from the action::circ_counts_by_year class, which is accessible to cstore/pcrud. A slightly more direct route would be to extend access to the extend_reporter::full_circ_count class outside of open-ils.reporter-store, but that seems like a bigger discussion.

Changed in evergreen:
milestone: 2.next → 2.7.2
milestone: 2.7.2 → 2.next
Revision history for this message
Chris Sharp (chrissharp123) wrote :
tags: added: signedoff
Revision history for this message
Ben Shum (bshum) wrote :

Pushed with Chris' signoff to master and backported to rel_2_7 and rel_2_6. Thanks all!

Changed in evergreen:
status: Confirmed → Fix Committed
milestone: 2.next → 2.7.2
Galen Charlton (gmc)
Changed in evergreen:
milestone: 2.7.2 → 2.next
Revision history for this message
Ben Shum (bshum) wrote :

Removing 2.next top level milestone, since this was a bug fix that was repaired in an actual series maintenance release.

Changed in evergreen:
milestone: 2.next → none
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.