diff --git a/app/resto/core/RestoConstants.php b/app/resto/core/RestoConstants.php index 77018bc2..156c9985 100644 --- a/app/resto/core/RestoConstants.php +++ b/app/resto/core/RestoConstants.php @@ -20,7 +20,7 @@ class RestoConstants // [IMPORTANT] Starting resto 7.x, default routes are defined in RestoRouter class // resto version - const VERSION = '9.0.0-RC9'; + const VERSION = '9.0.0-RC10'; /* ============================================================ * NEVER EVER TOUCH THESE VALUES diff --git a/app/resto/core/dbfunctions/CatalogsFunctions.php b/app/resto/core/dbfunctions/CatalogsFunctions.php index 867df00b..4bf7928d 100755 --- a/app/resto/core/dbfunctions/CatalogsFunctions.php +++ b/app/resto/core/dbfunctions/CatalogsFunctions.php @@ -727,8 +727,7 @@ private function getCleanLinks($catalog, $userid, $baseUrl) { } /* - * [TODO] Local collection -should not be in links but should appears in catalog - * under /catalogs/catalogThatIsIngested/{collectionId} so we can keep trace of this in item ?? + * Store local collection within links */ if ( $link['rel'] === 'child' && str_starts_with($link['href'], $baseUrl . RestoRouter::ROUTE_TO_COLLECTIONS )) { $output['links'][] = $link; diff --git a/app/resto/core/dbfunctions/FiltersFunctions.php b/app/resto/core/dbfunctions/FiltersFunctions.php index 18cba7fd..08bc6cd4 100755 --- a/app/resto/core/dbfunctions/FiltersFunctions.php +++ b/app/resto/core/dbfunctions/FiltersFunctions.php @@ -172,17 +172,29 @@ public function prepareFilters($paramsWithOperation, $sortKey) } $catalogFeatureTableName = $this->context->dbDriver->targetSchema . '.catalog_feature'; - if (count($flatTerms) == 1) { - - $this->joins[] = 'JOIN ' . $catalogFeatureTableName . ' ON ' . $this->context->dbDriver->targetSchema . '.feature.id=' . $catalogFeatureTableName . '.featureId'; - $filters[] = array( - 'value' => join(' AND ', array_merge($flatTerms)), - 'isGeo' => false - ); - - } - - // Nightmarish one - use WITH and having count + + /* + * Query to check for the existence of multiple specific paths. + * This is achieved using a combination of JOIN operations or GROUP BY to count the matching paths for each featureid. + * + * Using HAVING and GROUP BY : the idea is to group by featureid and ensure that the count of matched paths for each + * featureid equals the number of paths you are searching for. + * + * Example to search for 'years.2023' and 'platforms.s2a' + * + * SELECT featureid + * FROM resto.catalog_feature + * WHERE path IN (text2ltree('years.2023'), text2ltree('platforms.s2a')) + * GROUP BY featureid + * HAVING COUNT(DISTINCT path) = 2; -- Replace 2 with the number of paths you're checking + * + * Explanation : + * + * WHERE path IN (...): checks if the path is one of the specified paths. + * GROUP BY featureid: groups the results by featureid, so we can count how many paths match for each featureid + * HAVING COUNT(DISTINCT path) = X: ensures that the number of distinct paths for each featureid matches the number + * of paths we're looking for. Replace X with the number of paths we're querying for (e.g., 2 in the example). + */ $this->joins[] = 'JOIN matched_paths mp ON ' . $this->context->dbDriver->targetSchema . '.feature.id=mp.featureId'; $this->withs[] = 'WITH matched_paths AS ( SELECT featureid FROM ' . $catalogFeatureTableName . ' WHERE ' . join(' OR ', array_merge($flatTerms)) . ' GROUP BY featureid HAVING COUNT(DISTINCT ' . $catalogFeatureTableName . '.path) >= ' . count($flatTerms) . ')'; diff --git a/resto-database-model/03_resto_target_model.sql b/resto-database-model/03_resto_target_model.sql index d5c658f3..c00a9789 100644 --- a/resto-database-model/03_resto_target_model.sql +++ b/resto-database-model/03_resto_target_model.sql @@ -390,7 +390,10 @@ CREATE TABLE IF NOT EXISTS __DATABASE_TARGET_SCHEMA__.catalog ( visibility INTEGER, -- resto type - rtype TEXT + rtype TEXT, + + -- Free object to store info + properties JSON );