Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
snac
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
snac
snac
Commits
d4878f4c
Unverified
Commit
d4878f4c
authored
Jun 09, 2023
by
Joseph Glass
Committed by
GitHub
Jun 09, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #315 from snac-cooperative/development
Add NARA reports page
parents
75e536df
7a559562
Pipeline
#1235
passed with stages
in 15 minutes 55 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
227 additions
and
2 deletions
+227
-2
WebUIExecutor.php
src/snac/client/webui/WebUIExecutor.php
+17
-0
reporting.html
src/snac/client/webui/templates/dashboard/reporting.html
+15
-0
report_nara_stats_page.html
src/snac/client/webui/templates/report_nara_stats_page.html
+105
-0
ServerExecutor.php
src/snac/server/ServerExecutor.php
+22
-2
DBUtil.php
src/snac/server/database/DBUtil.php
+13
-0
SQL.php
src/snac/server/database/SQL.php
+55
-0
No files found.
src/snac/client/webui/WebUIExecutor.php
View file @
d4878f4c
...
...
@@ -1932,6 +1932,23 @@ class WebUIExecutor {
$display
->
setTemplate
(
"report_list_page"
);
break
;
case
"nara"
:
$ask
=
array
(
"command"
=>
"report"
,
"type"
=>
"nara"
,
);
$serverResponse
=
$this
->
connect
->
query
(
$ask
);
if
(
!
isset
(
$serverResponse
[
"result"
])
||
$serverResponse
[
"result"
]
!=
"success"
)
return
$this
->
drawErrorPage
(
$serverResponse
,
$display
);
if
(
isset
(
$this
->
permissions
[
"ViewAdminDashboard"
])
&&
$this
->
permissions
[
"ViewAdminDashboard"
])
{
$display
->
setData
(
$serverResponse
);
$display
->
setTemplate
(
"report_nara_stats_page"
);
}
else
{
$this
->
displayPermissionDeniedPage
(
"Admin Dashboard"
,
$display
);
}
break
;
case
"dashboard"
:
$display
->
setTemplate
(
"dashboard/reporting"
);
break
;
...
...
src/snac/client/webui/templates/dashboard/reporting.html
View file @
d4878f4c
...
...
@@ -160,6 +160,21 @@ $.fn.modal.Constructor.prototype.enforceFocus = $.noop;
</div>
{% endif %}
</div>
<div
class=
"col-md-4"
>
<!-- Right column -->
{% if permissions.ViewAdminDashboard %}
<div
class=
"panel panel-warning"
>
<div
class=
"panel-heading"
>
<h3
class=
"panel-title"
>
NARA Reports
</h3>
</div>
<div
class=
"panel-body"
>
<div
class=
"list-group"
>
<a
href=
"{{control.snacURL}}/reports/nara"
class=
"list-group-item"
><i
class=
"fa fa-list fa-fw"
aria-hidden=
"true"
></i>
NARA Edit Stats
</a>
</div>
</div>
</div>
{% endif %}
</div>
</div>
<div
class=
"row"
>
...
...
src/snac/client/webui/templates/report_nara_stats_page.html
0 → 100644
View file @
d4878f4c
<!DOCTYPE html>
<html>
<head>
<title>
Outbound Links Report - Social Networks and Archival Context
</title>
<!-- JQuery -->
<script
src=
"https://code.jquery.com/jquery-2.1.4.min.js"
></script>
<!-- Latest compiled and minified CSS -->
<link
rel=
"stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
integrity=
"sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ=="
crossorigin=
"anonymous"
>
<!-- Optional theme -->
<link
rel=
"stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"
integrity=
"sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX"
crossorigin=
"anonymous"
>
<!-- Latest compiled and minified JavaScript -->
<script
src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"
integrity=
"sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ=="
crossorigin=
"anonymous"
></script>
<!-- Helper Scripts -->
<link
href=
"https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css"
rel=
"stylesheet"
>
<script
src=
"https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"
></script>
<!-- Select Upgrades -->
<link
href=
"https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2-rc.1/css/select2.min.css"
rel=
"stylesheet"
/>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2-rc.1/js/select2.min.js"
></script>
<link
rel=
"stylesheet"
href=
"{{control.snacURL}}/css/select2-bootstrap.min.css"
>
<link
rel=
"stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"
>
<!-- Datatables -->
<link
rel=
"stylesheet"
href=
"https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"
>
<script
src=
"https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"
></script>
<script
src=
"https://cdn.plot.ly/plotly-latest.min.js"
></script>
<!-- C3 chart library -->
<link
rel=
"stylesheet"
href=
"https://cdn.jsdelivr.net/npm/c3@0.4.18/c3.css"
>
<script
src=
"https://d3js.org/d3.v3.min.js"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/c3@0.4.18/c3.min.js"
></script>
<!-- SNAC Styles -->
<link
rel=
"stylesheet"
href=
"{{control.snacURL}}/css/snac.css{{control.noCache}}"
>
<!-- SNAC Javascript -->
<script
src=
"{{control.snacURL}}/javascript/admin.js{{control.noCache}}"
></script>
<script
src=
"{{control.snacURL}}/javascript/save_actions.js{{control.noCache}}"
></script>
<script
src=
"{{control.snacURL}}/javascript/select_loaders.js{{control.noCache}}"
></script>
<script
src=
"{{control.snacURL}}/javascript/scripts.js{{control.noCache}}"
></script>
<script
src=
"{{control.snacURL}}/javascript/relation_search.js{{control.noCache}}"
></script>
<script
src=
"{{control.snacURL}}/javascript/html2canvas.js{{control.noCache}}"
></script>
<script
src=
"{{control.snacURL}}/javascript/feedback.js{{control.noCache}}"
></script>
<style>
.theme-dropdown
.dropdown-menu
{
position
:
static
;
display
:
block
;
margin-bottom
:
20px
;
}
.snac
>
p
>
.btn
{
margin
:
5px
0
;
}
.snac
.navbar
.container
{
width
:
auto
;
}
</style>
</head>
<body
role=
"document"
>
{% from 'page_navigation.html' import topNavigation,footer %}
{{ topNavigation(X, user, permissions, control) }}
<div
class=
"container snac"
role=
"main"
>
<h1>
NARA Edits Report
</h1>
<ol
class=
"breadcrumb"
>
<li><a
href=
"{{control.snacURL}}/reports/dashboard"
>
Reports
</a></li>
<li>
NARA Edits Report
</li>
</ol>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h3
class=
"panel-title"
>
NARA Report for {{data.month|replace({", " : ""})}}
</h3>
</div>
<div
class=
"panel-body"
>
<h4>
Number of NARA edits in the past month: {{data.naraEditCount}}
</h4>
<h4>
Number of NARA publishes in the past month: {{data.naraPublishesCount}}
</h4>
<h4>
Number of referrals from SNAC to National Archive Catalog: {{data.naraReferralsCount}}
</h4>
<h4>
Number of NARA resources Edited in the past month: {{data.naraEditedResourcesCount}}
</h4>
<h4>
Total Current Number of NARA resources in SNAC: {{data.naraResourcesCount}}
</h4>
</div>
</div>
</div>
</div>
</div>
</div>
{{ footer(X, user, permissions, control) }}
</body>
</html>
src/snac/server/ServerExecutor.php
View file @
d4878f4c
...
...
@@ -3976,6 +3976,9 @@ class ServerExecutor {
case
"outbound"
:
// Outbound data is generated on the fly, instead of being pulled from a precompiled report
return
$this
->
readAnalytics
(
$input
);
break
;
case
"nara"
:
// NARA data is generated on the fly, instead of being pulled from a precompiled report
return
$this
->
readNaraReport
(
$input
);
break
;
case
"general"
:
default
:
break
;
...
...
@@ -4284,9 +4287,9 @@ class ServerExecutor {
}
/**
* Re
cor
d Analytics by Domain
* Re
a
d Analytics by Domain
*
* Re
cord outgoing link traffic hit
* Re
ad outgoing link traffic
*
* @param string[] $input Input array from the Server object
*/
...
...
@@ -4310,4 +4313,21 @@ class ServerExecutor {
$trafficData
[
"total"
]
=
json_encode
(
$visits
[
2
][
"Total"
]);
return
$trafficData
;
}
/**
* Get NARA edit counts
*
* Get NARA edits
*
* @param string[] $input Input array from the Server object
*/
public
function
readNaraReport
()
{
$naraStats
=
$this
->
cStore
->
readNaraReport
();
if
(
!
isset
(
$naraStats
))
{
return
[
"result"
=>
"failure"
];
}
$naraStats
[
"result"
]
=
"success"
;
return
$naraStats
;
}
}
src/snac/server/database/DBUtil.php
View file @
d4878f4c
...
...
@@ -5195,6 +5195,19 @@ class DBUtil
return
$visits
;
}
/**
* Read NARA Report
*
* Read stats for NARA entities from the last month
*
* @return array $results
*/
public
function
readNaraReport
()
{
$results
=
$this
->
sql
->
selectNaraStats
();
if
(
isset
(
$results
[
'naraEditCount'
]))
return
$results
;
}
}
src/snac/server/database/SQL.php
View file @
d4878f4c
...
...
@@ -6889,6 +6889,61 @@ class SQL
return
$results
;
}
/**
* Select NARA Stats
*
* Read stats for NARA entities from the last month
*
* @return array $results Array of dates and hit counts
*/
public
function
selectNaraStats
()
{
// ID 83561837 - Including Jerry's non-NARA account in the stats
$sql
=
"SELECT to_char((current_date - interval '1' month), 'Month, yyyy') as current_month,
count(*) FROM version_history
WHERE timestamp BETWEEN date_trunc('month', current_date - interval '1' month) AND date_trunc('month', current_date)
AND user_id IN (SELECT id FROM appuser WHERE work_email ilike '%nara.gov' or id = 83561837);"
;
$result
=
$this
->
sdb
->
query
(
$sql
,
array
());
$naraEditCount
=
$this
->
sdb
->
fetchRow
(
$result
);
$sql
=
"SELECT count(*) FROM version_history
WHERE timestamp BETWEEN date_trunc('month', current_date - interval '1' month) AND date_trunc('month', current_date)
AND status IN ('published') AND user_id IN (SELECT id FROM appuser WHERE work_email ilike '%nara.gov' or id = 83561837);"
;
$result
=
$this
->
sdb
->
query
(
$sql
,
array
());
$naraPublishesCount
=
$this
->
sdb
->
fetchRow
(
$result
);
$sql
=
"SELECT count(*) FROM outbound_link
WHERE url ilike '%catalog.archives.gov%'
AND timestamp BETWEEN date_trunc('month', current_date - interval '1' month) AND date_trunc('month', current_date);"
;
$result
=
$this
->
sdb
->
query
(
$sql
,
array
());
$naraReferralsCount
=
$this
->
sdb
->
fetchRow
(
$result
);
$sql
=
"SELECT count(distinct id) FROM resource_cache
WHERE href ilike '%catalog.archives.gov%'
AND updated_at BETWEEN date_trunc('month', current_date - interval '1' month) AND date_trunc('month', current_date);"
;
$result
=
$this
->
sdb
->
query
(
$sql
,
array
());
$naraEditedResourcesCount
=
$this
->
sdb
->
fetchRow
(
$result
);
$sql
=
"SELECT count(distinct id) FROM resource_cache
WHERE href ilike '%catalog.archives.gov%';"
;
$result
=
$this
->
sdb
->
query
(
$sql
,
array
());
$naraTotalResourceCount
=
$this
->
sdb
->
fetchRow
(
$result
);
$sql
=
"SELECT count(distinct id) FROM resource_cache
WHERE href ilike '%catalog.archives.gov%' and is_deleted;"
;
$result
=
$this
->
sdb
->
query
(
$sql
,
array
());
$naraDeletedResourceCount
=
$this
->
sdb
->
fetchRow
(
$result
);
$results
=
[];
$results
[
'month'
]
=
$naraEditCount
[
'current_month'
];
$results
[
'naraEditCount'
]
=
$naraEditCount
[
'count'
];
$results
[
'naraPublishesCount'
]
=
$naraPublishesCount
[
'count'
];
$results
[
'naraReferralsCount'
]
=
$naraReferralsCount
[
'count'
];
$results
[
'naraResourcesCount'
]
=
(
int
)
$naraTotalResourceCount
[
'count'
]
-
(
int
)
$naraDeletedResourceCount
[
'count'
];
$results
[
'naraEditedResourcesCount'
]
=
$naraEditedResourcesCount
[
'count'
];
return
$results
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment