Skip to content

Commit

Permalink
Merge pull request #426 from jjrom/I419-rewrite-facet
Browse files Browse the repository at this point in the history
Remove dead code
  • Loading branch information
jjrom authored Jul 1, 2024
2 parents 1922fd6 + d99c53a commit e45793e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/resto/core/RestoConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-RC4';
const VERSION = '9.0.0-RC5';

/* ============================================================
* NEVER EVER TOUCH THESE VALUES
Expand Down
32 changes: 0 additions & 32 deletions app/resto/core/dbfunctions/GeneralFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,6 @@ public function tableExists($schemaName, $tableName)
return !empty($results);
}

/**
*
* Return keywords from database
*
* @param string $language : ISO A2 language code
*
* @return array
* @throws Exception
*/
public function getKeywords($language = 'en', $types = array())
{
$keywords = array();
$results = $this->dbDriver->query('SELECT name, public.normalize(name) as normalized, type, value, location FROM ' . $this->dbDriver->commonSchema . '.keyword WHERE ' . 'lang IN(\'' . pg_escape_string($this->dbDriver->getConnection(), $language) . '\', \'**\')' . (count($types) > 0 ? ' AND type IN(' . join(',', $types) . ')' : ''));
while ($result = pg_fetch_assoc($results)) {
if (!isset($keywords[$result['type']])) {
$keywords[$result['type']] = array();
}
$keywords[$result['type']][$result['normalized']] = array(
'name' => $result['name'],
'value' => $result['value']
);
if (isset($result['location'])) {
list($isoa2, $bbox) = explode(RestoConstants::TAG_SEPARATOR, $result['location']);
$keywords[$result['type']][$result['normalized']]['bbox'] = $bbox;
$keywords[$result['type']][$result['normalized']]['isoa2'] = $isoa2;
}
}

return array('keywords' => $keywords);
}


/**
* Returns shared link initiator email if resource is shared (checked with proof)
* Returns false otherwise
Expand Down
50 changes: 50 additions & 0 deletions facet_to_catalog.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- Step 1: Create the new table
CREATE TABLE resto.catalog_test (
id TEXT,
description TEXT
);

-- Step 2 & 3: Recursive query and insert into new table
WITH RECURSIVE cte AS (
-- Anchor member: Select the root nodes
SELECT
id AS original_id,
id AS newid,
id AS hashtag,
description,
pid
FROM
resto.facet
WHERE
pid = 'root'

UNION ALL

-- Recursive member: Join with child nodes
SELECT
child.id AS original_id,
CONCAT(cte.newid, '/', child.id) AS newid,
child.id as hashtag,
child.description,
child.pid
FROM
resto.facet AS child
INNER JOIN cte ON cte.original_id = child.pid
)

-- Insert the final results into the new table
-- INSERT INTO resto.catalog_test (id, description)
SELECT
newid,
title,
description,
level,
counters,
owner,
now() as created,
links,
visibility,
rtype,
hashtag
FROM
cte;
3 changes: 0 additions & 3 deletions resto-database-model/03_resto_target_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,6 @@ CREATE TABLE IF NOT EXISTS __DATABASE_TARGET_SCHEMA__.catalog (
-- Number of levels for this catalog
level INTEGER,

-- Number of items within this catalog
counter INTEGER,

-- Number of items within this catalog (total and per collection)
counters JSON,

Expand Down

0 comments on commit e45793e

Please sign in to comment.