<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.eprints.org/w/index.php?action=history&amp;feed=atom&amp;title=Departmental_report_script</id>
	<title>Departmental report script - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.eprints.org/w/index.php?action=history&amp;feed=atom&amp;title=Departmental_report_script"/>
	<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Departmental_report_script&amp;action=history"/>
	<updated>2026-05-06T02:16:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.8</generator>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Departmental_report_script&amp;diff=11246&amp;oldid=prev</id>
		<title>Mooread@liv.ac.uk: added github link</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Departmental_report_script&amp;diff=11246&amp;oldid=prev"/>
		<updated>2015-06-17T12:47:17Z</updated>

		<summary type="html">&lt;p&gt;added github link&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 12:47, 17 June 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Now on github!! [[https://github.com/adammoore/ep-dept-report]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We're trying to track usage of our eprints repo by department. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We're trying to track usage of our eprints repo by department. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mooread@liv.ac.uk</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Departmental_report_script&amp;diff=11200&amp;oldid=prev</id>
		<title>Mooread@liv.ac.uk at 09:35, 20 May 2015</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Departmental_report_script&amp;diff=11200&amp;oldid=prev"/>
		<updated>2015-05-20T09:35:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 09:35, 20 May 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l11&quot; &gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Apologies for hacky code!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Apologies for hacky code!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Put into &lt;/del&gt;your eprints bin directory&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;save as repo-department-report.pl in &lt;/ins&gt;your eprints bin directory&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Run with the following - you can capture the output with something like &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;pre&amp;gt; &lt;/del&gt;&amp;gt; dept-report.txt&amp;lt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;/pre&lt;/del&gt;&amp;gt; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Run with the following - you can capture the output with something like &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'' &lt;/ins&gt;&amp;gt; dept-report.txt&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'' &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''perl repo-department-report.pl &lt;/ins&gt;&amp;lt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;REPOSITORY&lt;/ins&gt;&amp;gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mooread@liv.ac.uk</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Departmental_report_script&amp;diff=11199&amp;oldid=prev</id>
		<title>Mooread@liv.ac.uk: Created page with 'We're trying to track usage of our eprints repo by department.   First, we made sure to refresh the user index with:  &lt;pre&gt; ./epadmin reindex &lt;REPOSITORY&gt; user &lt;/pre&gt;  Then this …'</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Departmental_report_script&amp;diff=11199&amp;oldid=prev"/>
		<updated>2015-05-20T09:32:59Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;We&amp;#039;re trying to track usage of our eprints repo by department.   First, we made sure to refresh the user index with:  &amp;lt;pre&amp;gt; ./epadmin reindex &amp;lt;REPOSITORY&amp;gt; user &amp;lt;/pre&amp;gt;  Then this …&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;We're trying to track usage of our eprints repo by department. &lt;br /&gt;
&lt;br /&gt;
First, we made sure to refresh the user index with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./epadmin reindex &amp;lt;REPOSITORY&amp;gt; user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then this script gives an output to STDOUT and a CSV file - we're interested in 'new' outputs that have an eprintID over 2,000,000 but I'm sure you could use another test, such as the date in the [[SCONUL_Report]]&lt;br /&gt;
&lt;br /&gt;
Apologies for hacky code!&lt;br /&gt;
&lt;br /&gt;
Put into your eprints bin directory&lt;br /&gt;
&lt;br /&gt;
Run with the following - you can capture the output with something like &amp;lt;pre&amp;gt; &amp;gt; dept-report.txt&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/perl -I/eprints/eprints3/perl_lib&lt;br /&gt;
&lt;br /&gt;
use strict;&lt;br /&gt;
use warnings;&lt;br /&gt;
use Data::Dumper;&lt;br /&gt;
&lt;br /&gt;
open DEPTREPORT,  &amp;quot;&amp;gt;dept-report.csv&amp;quot; or die &amp;quot; can't open report file dept-report.csv: $!&amp;quot;;&lt;br /&gt;
print DEPTREPORT &amp;quot;Department Name, Number of Staff, Total Items, Items with ID over 2M, Public Docs, Private Docs\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
my $date_value = '-2014-06-31'; #all dates up to June 31st 2014&lt;br /&gt;
use EPrints;&lt;br /&gt;
binmode(STDOUT, ':utf8');&lt;br /&gt;
&lt;br /&gt;
my $repositoryid = $ARGV[0];&lt;br /&gt;
die &amp;quot;USAGE: report.pl *repositoryid* \n&amp;quot; unless $repositoryid ;&lt;br /&gt;
&lt;br /&gt;
my $ep = EPrints-&amp;gt;new();&lt;br /&gt;
my $repo = $ep-&amp;gt;repository( $repositoryid );&lt;br /&gt;
my $deptid;&lt;br /&gt;
&lt;br /&gt;
die &amp;quot;Could not create repository object for $repositoryid\n&amp;quot; unless $repositoryid;&lt;br /&gt;
&lt;br /&gt;
my $sql = 'select distinct DEPT from &amp;quot;USER&amp;quot;';&lt;br /&gt;
        my $sth = $repo-&amp;gt;get_database-&amp;gt;prepare( $sql );&lt;br /&gt;
        $sth-&amp;gt;execute;&lt;br /&gt;
&lt;br /&gt;
        while(my @row = $sth-&amp;gt;fetchrow_array)&lt;br /&gt;
        {&lt;br /&gt;
                $deptid = @row[0];&lt;br /&gt;
                print &amp;quot;Department: $deptid\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
my $us = $repo-&amp;gt;dataset('user');&lt;br /&gt;
my $usearch = $us-&amp;gt;prepare_search();&lt;br /&gt;
&lt;br /&gt;
$usearch-&amp;gt;add_field($us-&amp;gt;field('dept'), $deptid);&lt;br /&gt;
&lt;br /&gt;
my $ulist = $usearch-&amp;gt;perform_search;&lt;br /&gt;
my $ids = $ulist-&amp;gt;ids;&lt;br /&gt;
#print Dumper $ids;&lt;br /&gt;
print $ulist-&amp;gt;count.&amp;quot; members of staff\n&amp;quot;;&lt;br /&gt;
my $ds = $repo-&amp;gt;dataset('archive');&lt;br /&gt;
&lt;br /&gt;
my $counts = {};&lt;br /&gt;
foreach my $id (@$ids){&lt;br /&gt;
my $search = $ds-&amp;gt;prepare_search();&lt;br /&gt;
#print $id.&amp;quot; . &amp;quot;;&lt;br /&gt;
$search-&amp;gt;add_field($ds-&amp;gt;field('eprint_status'), 'archive');&lt;br /&gt;
$search-&amp;gt;add_field($ds-&amp;gt;field('userid'), $id);&lt;br /&gt;
my $list = $search-&amp;gt;perform_search;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$list-&amp;gt;map( sub&lt;br /&gt;
{&lt;br /&gt;
        my ($repo, $ds, $dataobj, $counts) = @_;&lt;br /&gt;
&lt;br /&gt;
        my @docs = $dataobj-&amp;gt;get_all_documents;&lt;br /&gt;
        my $public = 0;&lt;br /&gt;
        my $private = 0;&lt;br /&gt;
        foreach my $doc (@docs)&lt;br /&gt;
        {&lt;br /&gt;
                if ($doc-&amp;gt;value('security') eq 'public')&lt;br /&gt;
                {&lt;br /&gt;
                        $public++;&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        $private++;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        if ($public)&lt;br /&gt;
        {&lt;br /&gt;
                $counts-&amp;gt;{public}++;&lt;br /&gt;
        }&lt;br /&gt;
        elsif ($private)&lt;br /&gt;
        {&lt;br /&gt;
                $counts-&amp;gt;{private}++;&lt;br /&gt;
        }&lt;br /&gt;
        if ($dataobj-&amp;gt;get_value(&amp;quot;eprintid&amp;quot;) &amp;gt;2000000) {$counts-&amp;gt;{new}++;}&lt;br /&gt;
        $counts-&amp;gt;{total}++;&lt;br /&gt;
&lt;br /&gt;
}, $counts);&lt;br /&gt;
}&lt;br /&gt;
print Dumper $counts;&lt;br /&gt;
if ($counts-&amp;gt;{total}){print DEPTREPORT &amp;quot;\&amp;quot;&amp;quot;$deptid.&amp;quot;\&amp;quot; , &amp;quot;.$usearch-&amp;gt;count.&amp;quot; , &amp;quot;.$counts-&amp;gt;{total}.&amp;quot; , &amp;quot;.$counts-&amp;gt;{new}.&amp;quot; , &amp;quot;.$counts-&amp;gt;{public}.&amp;quot; , &amp;quot;.$counts-&amp;gt;{private}.&amp;quot;\n&amp;quot;;}&lt;br /&gt;
}&lt;br /&gt;
close DEPTREPORT;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mooread@liv.ac.uk</name></author>
		
	</entry>
</feed>