Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
parlapi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
David Guillot
parlapi
Commits
a4f3e1f2
Commit
a4f3e1f2
authored
Apr 15, 2017
by
Nicolas Joyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Amdts: ajout liste auteurs au vecteur TS
parent
5be488a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
1 deletion
+69
-1
migrations/versions/14e3a8ca0ec4_maj_trigger_ts_amendements.py
...tions/versions/14e3a8ca0ec4_maj_trigger_ts_amendements.py
+67
-0
parlapi/models.py
parlapi/models.py
+2
-1
No files found.
migrations/versions/14e3a8ca0ec4_maj_trigger_ts_amendements.py
0 → 100644
View file @
a4f3e1f2
"""Maj trigger TS amendements
Revision ID: 14e3a8ca0ec4
Revises: 0c154fdc1261
Create Date: 2017-04-15 07:56:45.263214
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'14e3a8ca0ec4'
down_revision
=
'0c154fdc1261'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
conn
=
op
.
get_bind
()
conn
.
execute
(
"""
CREATE OR REPLACE FUNCTION public.amendements_search_vector_update ()
RETURNS trigger
LANGUAGE plpgsql
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100
AS $$
BEGIN
NEW.search_vector = (((
to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.numero_long, ''), '[-@.]', ' ', 'g'))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_expose, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_dispositif, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi_division, ''), '[-@.]', ' ', 'g'))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.auteur_texte_affichable, ''), '[-@.]', ' ', 'g'));
RETURN NEW;
END
$$;
ALTER FUNCTION public.amendements_search_vector_update() OWNER TO parlapi;
"""
)
def
downgrade
():
conn
=
op
.
get_bind
()
conn
.
execute
(
"""
CREATE OR REPLACE FUNCTION public.amendements_search_vector_update ()
RETURNS trigger
LANGUAGE plpgsql
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100
AS $$
BEGIN
NEW.search_vector = (((
to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.numero_long, ''), '[-@.]', ' ', 'g'))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_expose, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.corps_dispositif, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi, ''), '[-@.]', ' ', 'g')))
|| to_tsvector('pg_catalog.french', regexp_replace(coalesce(NEW.code_loi_division, ''), '[-@.]', ' ', 'g'));
RETURN NEW;
END
$$;
ALTER FUNCTION public.amendements_search_vector_update() OWNER TO parlapi;
"""
)
parlapi/models.py
View file @
a4f3e1f2
...
...
@@ -430,7 +430,8 @@ class Amendement(db.Model):
search_vector
=
db
.
Column
(
TSVectorType
(
'numero_long'
,
'corps_expose'
,
'corps_dispositif'
,
'code_loi'
,
'code_loi_division'
))
'code_loi_division'
,
'auteur_texte_affichable'
))
class
ActeurAmendement
(
db
.
Model
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment