You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 28, 2020. It is now read-only.
CREATE TABLE `Station` (
`StationID` int(11) NOT NULL AUTO_INCREMENT,
-- ...
-- *no* `Tags` field here
-- ...
PRIMARY KEY (`StationID`)
)
CREATE TABLE `Tag` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `Station_Tag` (
`StationID` int(11) NOT NULL,
`TagID` int(11) NOT NULL
FOREIGN KEY (StationID)
REFERENCES Station(id),
FOREIGN KEY (TagID)
REFERENCES Tag(id)
)
I can't find where in the code TagCache gets populated; is there a cronjob that's not checked into the repo or am I missing something obvious? In any case, you could keep the table working by rewriting it as a view, and if performance becomes a problem you could materialize it (unfortunately with MySQL you need to write this manually). I think this should do it, but I haven't tested it, so it's just to show the idea:
CREATE VIEW TagCache AS
SELECT
Tag.id as TagID,
Tag.name as name,
count(*) as StationCount,
count(Station.working = 1) as StationCountWorking
FROM
-- this inner select deals with Stations having two IDs: a UUID and a SQL ID column
(SELECT Station.id as id, StationCheck.CheckOK as working
FROM
Station
INNER JOIN
StationCheck
WHERE Station.StationUuid = StationCheck.StationUuid) Station
INNER JOIN Station_Tag where Station.id = Station_Tag.StationID
INNER JOIN Tag where Tag.id = Station_Tag.TagID
GROUP BY TagID
I would like to write a migration to implement this change. It would make #56 easier for me.
The text was updated successfully, but these errors were encountered:
I took a look at the SQL dump and found that there is a TagCache table listing the tags, but that it is not related to the Stations table.
The current database has tags just stored as a string delimited by commas:
(here the tags are ["derechos humanos", "jesuit", "el progreso"])
and there's a /cache/ which I assume gets rebuilt manually somewhere:
This situation is a many-to-many relationship and it would be cleaner to use an intermediate "junction" table:
I can't find where in the code TagCache gets populated; is there a cronjob that's not checked into the repo or am I missing something obvious? In any case, you could keep the table working by rewriting it as a view, and if performance becomes a problem you could materialize it (unfortunately with MySQL you need to write this manually). I think this should do it, but I haven't tested it, so it's just to show the idea:
I would like to write a migration to implement this change. It would make #56 easier for me.
The text was updated successfully, but these errors were encountered: