Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions v1/random/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@

// ======= REQUIRED api.env VARIABLES =======
// This script expects the following variables in api.env:
// PROD_SERVER=<solr_server_url> (e.g., http://localhost:8983 or https://solr.example.com)
// SOLR_SERVER=<solr_server_url> (e.g., http://localhost:8983 or https://solr.example.com)
// SOLR_USER=<solr_username>
// SOLR_PASS=<solr_password>
// =======================================

$PROD_SERVER = trim(getenv('PROD_SERVER') ?: '');
$SOLR_SERVER = trim(getenv('SOLR_SERVER') ?: '');
$SOLR_USER = trim(getenv('SOLR_USER') ?: '');
$SOLR_PASS = trim(getenv('SOLR_PASS') ?: '');
$PROTOCOL = trim(getenv('PROTOCOL') ?: '');

if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
http_response_code(405);
Expand Down Expand Up @@ -94,12 +95,12 @@ function fetchJson(string $url, ?string $user = null, ?string $pass = null, int
}

try {
if (!$PROD_SERVER) {
throw new Exception("PROD_SERVER not set");
if (!$SOLR_SERVER) {
throw new Exception("SOLR_SERVER not set");
}

$core = 'job';
$base = "http://$PROD_SERVER/solr/$core/select";
$base = "$PROTOCOL://$SOLR_SERVER/solr/$core/select";

$countUrl = $base . '?q=*:*&rows=0';
error_log("RANDOM COUNT URL: $countUrl");
Expand Down
Loading