- bug: error if dataset table is empty

This commit is contained in:
Arno Kaimbacher 2020-03-05 16:03:34 +01:00
parent c0022e3c1c
commit 0fd0f02537
2 changed files with 4 additions and 3 deletions

View File

@ -149,7 +149,7 @@ class RequestController extends Controller
$repositoryName = "Tethys RDR"; $repositoryName = "Tethys RDR";
$repIdentifier = "tethys.geologie.ac.at"; $repIdentifier = "tethys.geologie.ac.at";
$sampleIdentifier = "oai:" . $repIdentifier . ":27";//$this->_configuration->getSampleIdentifier(); $sampleIdentifier = "oai:" . $repIdentifier . ":27";//$this->_configuration->getSampleIdentifier();
$earliestDateFromDb = optional(Dataset::earliestPublicationDate())->server_date_published; $earliestDateFromDb = Dataset::earliestPublicationDate() != null ? Dataset::earliestPublicationDate()->server_date_published: null;
// set parameters for oai-pmh.xslt // set parameters for oai-pmh.xslt
$this->_proc->setParameter('', 'email', $email); $this->_proc->setParameter('', 'email', $email);

View File

@ -258,17 +258,18 @@ class Dataset extends Model
* *
* @return \Carbon\Carbon\Date * @return \Carbon\Carbon\Date
*/ */
public function scopeEarliestPublicationDate($query, string $column = null) public static function earliestPublicationDate(string $column = null)
{ {
if (!$column) { if (!$column) {
$column = self::PUBLISHED_AT; $column = self::PUBLISHED_AT;
} }
return $query->select('server_date_published') $result = Dataset::select('server_date_published')
->where('server_date_published', '<>', null) ->where('server_date_published', '<>', null)
->where('server_state', 'published') ->where('server_state', 'published')
->orderBy('server_date_published', 'asc') ->orderBy('server_date_published', 'asc')
->first(); ->first();
//->server_date_published; //->server_date_published;
return $result;
} }
public function setServerState($targetType) public function setServerState($targetType)