SCONUL Report

From EPrints Documentation
Revision as of 11:35, 22 January 2015 by Af05v@ecs.soton.ac.uk (talk | contribs) (Created page with '<pre> #!/usr/bin/perl -I/opt/eprints/eprints3/perl_lib use strict; use warnings; my $date_value = '-2014-06-31'; #all dates up to June 31st 2014 use EPrints; binmode(STDOUT, '…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

#!/usr/bin/perl -I/opt/eprints/eprints3/perl_lib

use strict;
use warnings;

my $date_value = '-2014-06-31'; #all dates up to June 31st 2014
use EPrints;
binmode(STDOUT, ':utf8');

my $repositoryid = $ARGV[0];
die "report.pl *repositoryid*\n" unless $repositoryid;

my $ep = EPrints->new();
my $repo = $ep->repository( $repositoryid );

die "Could not create repository object for $repositoryid\n" unless $repository;

my $ds = $repo->dataset('archive');

my $search = $ds->prepare_search();

$search->add_field($ds->field('eprint_status'), 'archive');
$search->add_field($ds->field('datestamp'), $date_value);
my $list = $search->perform_search;

my $counts = {};

$list->map( sub
{
        my ($repo, $ds, $dataobj, $counts) = @_;

        my @docs = $dataobj->get_all_documents;

        my $public = 0;
        my $private = 0;
        foreach my $doc (@docs)
        {
                if ($doc->value('security') eq 'public')
                {
                        $public++;
                }
                else
                {
                        $private++;
                }
        }

        if ($public)
        {
                $counts->{public}++;
        }
        elsif ($private)
        {
                $counts->{private}++;
        }
        $counts->{total}++;

}, $counts);

use Data::Dumper;
print Dumper $counts;