Skip to content

Commit

Permalink
usage of taxa thesaurus family over occurrence family (#1675)
Browse files Browse the repository at this point in the history
* usage of taxa thesaurus family over occurrence family

* Modifications

- "ts.taxauthid = 1" needs to be added to the where condition or the recordset would return duplicate records for each taxonomic thesaurus defined within taxstatus table (e.g. there are 4 defined within SEINet). I suppose not including it would not be a big problem since the occid would be the same for each record, and thus the output data array would just copy over existing data. However, it would iterate through more records than needed. Another solution would be to change the statement to "SELECT DISTINCT...", but this can significantly slows down an ordered query.
- Since "ts.taxauthid = 1" is added to the where clause, the getTableJoins function should always add the taxstatus left join, thus we can leave out that test.

* Minor fix to previous submit

---------

Co-authored-by: Edward Gilbert <[email protected]>
  • Loading branch information
MuchQuak and egbot authored Aug 28, 2024
1 parent 6279f1e commit 71f9b8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion classes/OccurrenceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ protected function getTableJoins($sqlWhere){
if(strpos($sqlWhere,'e.taxauthid')){
$sqlJoin .= 'INNER JOIN taxaenumtree e ON o.tidinterpreted = e.tid ';
}
if(strpos($sqlWhere,'ts.family')){
if(strpos($sqlWhere,'ts.')){
$sqlJoin .= 'LEFT JOIN taxstatus ts ON o.tidinterpreted = ts.tid ';
}
if(strpos($sqlWhere,'ds.datasetid')){
Expand Down
7 changes: 6 additions & 1 deletion classes/OccurrenceMapManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ public function getCoordinateMap($start, $limit){
if($this->sqlWhere){
$statsManager = new OccurrenceAccessStats();
$sql = 'SELECT o.occid, CONCAT_WS(" ",o.recordedby,IFNULL(o.recordnumber,o.eventdate)) AS identifier, '.
'o.sciname, o.family, o.tidinterpreted, o.DecimalLatitude, o.DecimalLongitude, o.collid, o.catalognumber, '.
'o.sciname, IF(ts.family IS NULL, o.family, ts.family) as family, o.tidinterpreted, o.DecimalLatitude, o.DecimalLongitude, o.collid, o.catalognumber, '.
'o.othercatalognumbers, c.institutioncode, c.collectioncode, c.CollectionName '.
'FROM omoccurrences o INNER JOIN omcollections c ON o.collid = c.collid ';

$this->sqlWhere .= 'AND ts.taxauthid = 1 ';

$sql .= $this->getTableJoins($this->sqlWhere);

$sql .= $this->sqlWhere;

if(is_numeric($start) && $limit){
$sql .= "LIMIT ".$start.",".$limit;
}
Expand Down

0 comments on commit 71f9b8e

Please sign in to comment.