[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] IRstats2 & MePrints.



All,

I have been working on a MePrints Widget for IRstats2 for a while now and I'm finding that the MD5 checksum that is displayed when using the /cgi/stats/report URL filtering on Author does not create the same MD5 checksum in the URL as does when using the code below (found in the cfg/plugins/EPrints/Plugin/Stats/Sets.pm file).

$userid = '4';
$val = Digest::MD5::md5_hex( encode_utf8($userid) );
print "$val\n";
a87ff679a2f3e71d9181a67b7542122c

I've also just tried simply:
$val = Digest::MD5::md5_hex($userid);
a87ff679a2f3e71d9181a67b7542122c

For example (not sure if this is accessible outside our network) the following returns properly for the author as in all of the statistics are correct:
http://d-scholarship-dev-3.library.pitt.edu/cgi/stats/report/authors/c3ecdb1a4078bd398ff4bed89666e4f4/

However, when I try to embed the same stats into a widget for meprints (code below)  I get a different MD5 value (a87ff679a2f3e71d9181a67b7542122c) thus the MD5 values don't match and as such the stats are incorrect (or actually missing obviously).  Otherwise the widget works as expected displaying both the downloads and top 5 eprints IRstats graphs - however the widget usually shows 0 for downloads and "No data found." for the author.

What am I missing or is there something in my settings for IRstats that needs changed?

Thanks,
Brian Gregg.


My IRstats Author Widget Code:

package EPrints::Plugin::MePrints::Widget::IRStats2Author;

use EPrints::Plugin::MePrints::Widget;
@ISA = ( 'EPrints::Plugin::MePrints::Widget' );

use strict;
use Encode;

sub new
{

        my( $class, %params ) = @_;

        my $self = $class->SUPER::new( %params );

        if ( !$self->{session} )
        {
                $self->{session} = $self->{processor}->{session};
        }

       $self->{name} = "EPrints Profile System: IRStats Author Widget";
        $self->{visible} = "all";
        $self->{advertise} = 1;
        $self->{max_display} = 10;

        if( defined $self->{session} && defined $self->{session}->current_user )
        {
                unless( $self->{session}->current_user->has_role( 'deposit' ) )
                {
                        $self->{enable} = 0;
                }
        }

        return $self;
}

sub render_content
{
        my( $self ) = @_;

       my $session = $self->{session};
        my $user = $self->{user};
        my $username = $user->get_value( 'username' );
        my $orcid = $user->get_value( 'orcid' );

        my $frag = $session->make_doc_fragment;


        my $repo_url = $session->get_repository->get_conf( "base_url" );

        # just need a container, a JS callback, a way to translate the current user ID into a IRStats2 Set value (??)

        my $userid = $user->get_id;
        #my $set_value = Digest::MD5::md5_hex( $user->get_id );
        my $set_value = Digest::MD5::md5_hex( encode_utf8( $user->get_id ) );

        $frag->appendChild( $session->make_text( "$userid,$set_value" ) );

        $frag->appendChild( $self->html_phrase( "downloads" ) );

        $frag->appendChild( $session->make_element( 'div', id => 'irstats2_downloads', style => 'width: 300px; height: 100px;margin-left:auto;margin-right:auto;' ) );

        $frag->appendChild( $session->make_javascript( <<GRAPH ) );

new EPJS_Stats_GoogleGraph( { 'context': {
        'range': '1y',
        'datatype': 'downloads',
        'set_name': 'authors',
        'set_value': '$set_value'
}, 'options': {
        'container_id': 'irstats2_downloads'
} } );

GRAPH

        $frag->appendChild( $self->html_phrase( "top" ) );

        $frag->appendChild( $session->make_element( 'div', id => 'irstats2_top' ) );

        $frag->appendChild( $session->make_javascript( <<TABLE ) );

new EPJS_Stats_Table( { 'context': {
        'range': '_ALL_',
        'datatype': 'downloads',
        'set_name': 'authors',
        'set_value': '$set_value'
}, 'options': {
        'container_id': 'irstats2_top',
        'top': 'eprint',
        'limit': '5'
} } );
TABLE

        return $frag;
}

1;



Brian D. Gregg
Solutions Architect | Manager Systems Development
University of Pittsburgh | University Library System
Address: 7500 Thomas Blvd.  Room 129 Pittsburgh, PA 15208<https://maps.google.com/maps?q=7500+Thomas+Blvd,+Pittsburgh,+PA&hl=en&sll=41.117935,-77.604698&sspn=7.662465,13.73291&oq=7500+Tho&t=h&hnear=7500+Thomas+Blvd,+Pittsburgh,+Pennsylvania+15208&z=17>
Tel: (412) 648-3264 | Email: bdgregg at pitt.edu<mailto:bdgregg at pitt.edu> | Fax: (412) 648-3585

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20150831/cee3df5c/attachment-0001.html