-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add full text search for bookmarks, episodes and archives.
- Loading branch information
Showing
61 changed files
with
1,913 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
-- Bookmarks FTS | ||
alter table bookmarks | ||
add column tsv tsvector; | ||
|
||
create index bookmarks_tsv_idx on bookmarks using gin(tsv); | ||
|
||
|
||
update bookmarks set tsv = | ||
setweight(to_tsvector('english', coalesce(note,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(title,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(summary,'')), 'C') || | ||
setweight(to_tsvector('english', coalesce(url,'')), 'C'); | ||
|
||
create function bookmarks_tsv_update() returns trigger as $$ | ||
begin | ||
new.tsv := | ||
setweight(to_tsvector('english', coalesce(NEW.note,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(NEW.title,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(NEW.summary,'')), 'C') || | ||
setweight(to_tsvector('english', coalesce(NEW.url,'')), 'C'); | ||
return new; | ||
end | ||
$$ language plpgsql; | ||
|
||
create trigger bookmarks_tsv_trigger before insert or update | ||
on bookmarks for each row execute function bookmarks_tsv_update(); | ||
|
||
-- Archives FTS | ||
alter table archives | ||
add column tsv tsvector; | ||
|
||
create index archives_tsv_idx on archives using gin(tsv); | ||
|
||
|
||
update archives set tsv = | ||
setweight(to_tsvector('english', coalesce(title,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(text_content,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(excerpt,'')), 'C') || | ||
setweight(to_tsvector('english', coalesce(site_name,'')), 'D') || | ||
setweight(to_tsvector('english', coalesce(byline,'')), 'D') || | ||
setweight(to_tsvector('english', coalesce(url,'')), 'D'); | ||
|
||
|
||
create function archives_tsv_update() returns trigger as $$ | ||
begin | ||
new.tsv := | ||
setweight(to_tsvector('english', coalesce(NEW.title,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(NEW.text_content,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(NEW.excerpt,'')), 'C') || | ||
setweight(to_tsvector('english', coalesce(NEW.site_name,'')), 'D') || | ||
setweight(to_tsvector('english', coalesce(NEW.byline,'')), 'D') || | ||
setweight(to_tsvector('english', coalesce(NEW.url,'')), 'D'); | ||
return new; | ||
end | ||
$$ language plpgsql; | ||
|
||
create trigger archives_tsv_trigger before insert or update | ||
on archives for each row execute function archives_tsv_update(); | ||
|
||
-- Episodes FTS | ||
alter table episodes | ||
add column tsv tsvector; | ||
|
||
create index episodes_tsv_idx on episodes using gin(tsv); | ||
|
||
|
||
update episodes set tsv = | ||
setweight(to_tsvector('english', coalesce(title,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(text_content,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(author_name,'')), 'C') || | ||
setweight(to_tsvector('english', coalesce(filename,'')), 'D') || | ||
setweight(to_tsvector('english', coalesce(url,'')), 'D'); | ||
|
||
|
||
create function episodes_tsv_update() returns trigger as $$ | ||
begin | ||
new.tsv := | ||
setweight(to_tsvector('english', coalesce(NEW.title,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(NEW.text_content,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(NEW.author_name,'')), 'C') || | ||
setweight(to_tsvector('english', coalesce(NEW.filename,'')), 'D') || | ||
setweight(to_tsvector('english', coalesce(NEW.url,'')), 'D'); | ||
return new; | ||
end | ||
$$ language plpgsql; | ||
|
||
create trigger episodes_tsv_trigger before insert or update | ||
on episodes for each row execute function episodes_tsv_update(); | ||
|
||
-- Users FTS | ||
alter table users | ||
add column tsv tsvector; | ||
|
||
create index users_tsv_idx on users using gin(tsv); | ||
|
||
|
||
update users set tsv = | ||
setweight(to_tsvector('english', coalesce(username,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(disabled_reason,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(internal_note,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(email,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(pending_email_update,'')), 'B'); | ||
|
||
|
||
create function users_tsv_update() returns trigger as $$ | ||
begin | ||
new.tsv := | ||
setweight(to_tsvector('english', coalesce(NEW.username,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(NEW.disabled_reason,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(NEW.internal_note,'')), 'A') || | ||
setweight(to_tsvector('english', coalesce(NEW.email,'')), 'B') || | ||
setweight(to_tsvector('english', coalesce(NEW.pending_email_update,'')), 'B'); | ||
return new; | ||
end | ||
$$ language plpgsql; | ||
|
||
create trigger users_tsv_trigger before insert or update | ||
on users for each row execute function users_tsv_update(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- Bookmarks FTS down | ||
drop trigger if exists bookmarks_tsv_trigger on bookmarks; | ||
drop function if exists bookmarks_tsv_update(); | ||
drop index if exists bookmarks_tsv_idx; | ||
alter table bookmarks drop column if exists tsv; | ||
|
||
-- Archives FTS down | ||
drop trigger if exists archives_tsv_trigger on archives; | ||
drop function if exists archives_tsv_update(); | ||
drop index if exists archives_tsv_idx; | ||
alter table archives drop column if exists tsv; | ||
|
||
-- Episodes FTS down | ||
drop trigger if exists episodes_tsv_trigger on episodes; | ||
drop function if exists episodes_tsv_update(); | ||
drop index if exists episodes_tsv_idx; | ||
alter table episodes drop column if exists tsv; | ||
|
||
-- Users FTS down | ||
drop trigger if exists users_tsv_trigger on users; | ||
drop function if exists users_tsv_update(); | ||
drop index if exists users_tsv_idx; | ||
alter table users drop column if exists tsv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default async function searchAdminUsersRoutes (fastify, opts) { | ||
await Promise.all([ | ||
|
||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.