Skip to content

Commit

Permalink
Merge pull request #131 from Chloe070196/refactor_API_usagegraphs
Browse files Browse the repository at this point in the history
fix: move API usage files to API folders
  • Loading branch information
ammopt authored Oct 9, 2024
2 parents f5746df + 53bbfb2 commit 37c0949
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<h3 class="dashboardCategoryLabel">{$method}{' '} {* No translation needed *}
<a href="/Admin/APIUsageGraphs?stat={$method}&instance={$selectedInstance}" title="{translate text="{$moduleName} Graph" inAttribute="true" isAdminFacing=true}">
<a href="/API/UsageGraphs?stat={$method}&instance={$selectedInstance}" title="{translate text="{$moduleName}: {$method} Graph" inAttribute="true" isAdminFacing=true}">
<i class="fas fa-chart-line"></i>
</a>
</h3>
Expand Down
1 change: 1 addition & 0 deletions code/web/release_notes/24.10.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

## Aspen Usage Data
- added usage graphs and raw data tables for the Axis360, Aspen API, and SideLoads usage dashboards, all of which include a CSV download feature. (*CZ*)
- change the urls for the API Usage Dashboard and API Usage graphs from /Admin/APIUsageDashboard to /API/UsageDashboard and /Admin/APIUsageGraphs to /API/UsageGraphs respectively. (*CZ*)

### Greenhouse Updates
- Add the ability to generate historical reading history data for a patron. Reading history can be generated for the past 1–6 years with a minimum and maximum number of reading history entries per month. Entries are generated at random from the grouped works in the database. The new tool is located at Greenhouse > Testing Tools > Generate Reading History. (*MDN*)
Expand Down
10 changes: 10 additions & 0 deletions code/web/services/API/AJAX.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require_once ROOT_DIR . '/JSON_Action.php';

class API_AJAX extends JSON_Action {
public function exportUsageData() {
require_once ROOT_DIR . '/services/API/UsageGraphs.php';
$aspenUsageGraph = new API_UsageGraphs();
$aspenUsageGraph->buildCSV();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require_once ROOT_DIR . '/services/Admin/Dashboard.php';
require_once ROOT_DIR . '/sys/SystemLogging/APIUsage.php';

class Admin_APIUsageDashboard extends Admin_Dashboard {
class API_UsageDashboard extends Admin_Dashboard {
function launch() {
global $interface;

Expand All @@ -24,7 +24,7 @@ function launch() {

$interface->assign('statsByModule', $statsByModule);

$this->display('api_usage_dashboard.tpl', 'Aspen Usage Dashboard');
$this->display('dashboard.tpl', 'Aspen Usage Dashboard');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once ROOT_DIR . '/services/Admin/Admin.php';
require_once ROOT_DIR . '/sys/SystemLogging/APIUsage.php';

class Admin_APIUsageGraphs extends Admin_Admin
class API_UsageGraphs extends Admin_Admin
{
function launch()
{
Expand All @@ -17,15 +17,15 @@ function launch()
}

$title = 'Aspen Discovery API Usage Graph';
$interface->assign('section', 'Admin');
$interface->assign('section', 'API');
$interface->assign('showCSVExportButton', true);
$interface->assign('graphTitle', $title);
$this->assignGraphSpecificTitle($stat);
$this->getAndSetInterfaceDataSeries($stat, $instanceName);
$interface->assign('stat', $stat);
$interface->assign('propName', 'exportToCSV');
$title = $interface->getVariable('graphTitle');
$this->display('usage-graph.tpl', $title);
$this->display('../Admin/usage-graph.tpl', $title);
}
function getBreadcrumbs(): array
{
Expand Down
15 changes: 2 additions & 13 deletions code/web/services/Admin/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -1664,20 +1664,9 @@ public function copyMenuLinks() {
return $result;
}

/* Aspen API Usage and general Aspen usage use the same graph template and AJAX file,
but different services.
This is reflected in the following control flow
*/
public function exportUsageData() {
$stat = $_REQUEST['stat'];

if ($stat == 'runPendingDatabaseUpdates') {
require_once ROOT_DIR . '/services/Admin/APIUsageGraphs.php';
$aspenUsageGraph = new Admin_APIUsageGraphs();
} else {
require_once ROOT_DIR . '/services/Admin/UsageGraphs.php';
$aspenUsageGraph = new Admin_UsageGraphs();
}
require_once ROOT_DIR . '/services/Admin/UsageGraphs.php';
$aspenUsageGraph = new Admin_UsageGraphs();
$aspenUsageGraph->buildCSV();
}
}
2 changes: 1 addition & 1 deletion code/web/sys/Account/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3640,7 +3640,7 @@ public function getAdminActions() {
'View Dashboards',
'View System Reports',
]);
$sections['system_reports']->addAction(new AdminAction('API Usage Dashboard', 'API Usage Report for Aspen Discovery.', '/Admin/APIUsageDashboard'), [
$sections['system_reports']->addAction(new AdminAction('API Usage Dashboard', 'API Usage Report for Aspen Discovery.', '/API/UsageDashboard'), [
'View Dashboards',
'View System Reports',
]);
Expand Down

0 comments on commit 37c0949

Please sign in to comment.