View | Details | Raw Unified | Return to bug 34223
Collapse All | Expand All

(-)a/Koha/Illbackend.pm (-14 / +12 lines)
Lines 48-63 Return a list of existing ILL statuses Link Here
48
sub existing_statuses {
48
sub existing_statuses {
49
    my ( $self, $backend_id ) = @_;
49
    my ( $self, $backend_id ) = @_;
50
50
51
    #FIXME: Currently fetching all requests, it'd be great if we could fetch distinct(status).
51
    # NOTE: This query fetches all distinct status's found in the database for this backend.
52
    # Even doing it with distinct status, we need the ILL request object, so that strings_map works and
52
    # We need the 'status' field for obvious reasons, the 'backend' field is required to not
53
    # the ILL request returns the correct status and info respective to its backend.
53
    # throw 'Koha::Exceptions::Ill::InvalidBackendId' when we're converting to a Koha object.
54
    # Finally, to get around 'ONLY_FULL_GROUP_BY', we have to be explicit about which
55
    # 'request_id' we want to return, hense the 'MAX' call.
54
    my $ill_requests = Koha::Illrequests->search(
56
    my $ill_requests = Koha::Illrequests->search(
55
            {backend => $backend_id},
57
        { backend => $backend_id },
56
            # {
58
        {
57
            #     columns => [ qw/status/ ],
59
            select   => [ 'status', \'MAX(illrequest_id)', 'backend' ],
58
            #     group_by => [ qw/status/ ],
60
            as       => [qw/ status illrequest_id backend /],
59
            # }
61
            group_by => [qw/status backend/],
60
        );
62
        }
63
    );
61
64
62
    my @data;
65
    my @data;
63
    while (my $request = $ill_requests->next) {
66
    while (my $request = $ill_requests->next) {
Lines 74-83 sub existing_statuses { Link Here
74
        }
77
        }
75
    }
78
    }
76
79
77
    # Remove duplicate statuses
78
    my %seen;
79
    @data =  grep { my $e = $_; my $key = join '___', map { $e->{$_}; } sort keys %$_;!$seen{$key}++ } @data;
80
81
    return \@data;
80
    return \@data;
82
}
81
}
83
82
84
- 

Return to bug 34223