Fix find_citizens SQL query
This commit is contained in:
6
Makefile
6
Makefile
@@ -21,9 +21,9 @@ build-docker: ## Build the docker image of application
|
|||||||
pd: publish-docker
|
pd: publish-docker
|
||||||
|
|
||||||
publish-docker: build-docker ## Publish docker image of application to Github
|
publish-docker: build-docker ## Publish docker image of application to Github
|
||||||
git diff --quiet --exit-code || (echo "The git is DIRTY !!! You cannot publish this crap!" && exit 1)
|
@git diff --quiet --exit-code || (echo "The git is DIRTY !!! You cannot publish this crap!" && exit 1)
|
||||||
cat ./GH_TOKEN.txt | docker login docker.pkg.github.com -u ${GITHUB_USERNAME} --password-stdin
|
@cat ./GH_TOKEN.txt | docker login docker.pkg.github.com -u ${GITHUB_USERNAME} --password-stdin
|
||||||
docker tag dc-project docker.pkg.github.com/flecomte/dc-project/dc-project:${VERSION}
|
@docker tag dc-project docker.pkg.github.com/flecomte/dc-project/dc-project:${VERSION}
|
||||||
docker push docker.pkg.github.com/flecomte/dc-project/dc-project:${VERSION}
|
docker push docker.pkg.github.com/flecomte/dc-project/dc-project:${VERSION}
|
||||||
|
|
||||||
rd: run-docker
|
rd: run-docker
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ create or replace function find_citizens(
|
|||||||
) language plpgsql as
|
) language plpgsql as
|
||||||
$$
|
$$
|
||||||
begin
|
begin
|
||||||
select json_agg(t), (select count(id) from citizen)
|
select json_agg(t) into resource
|
||||||
into resource, total
|
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
z.*,
|
z.*,
|
||||||
@@ -38,6 +37,13 @@ begin
|
|||||||
z.created_at desc
|
z.created_at desc
|
||||||
limit "limit" offset "offset"
|
limit "limit" offset "offset"
|
||||||
) as t;
|
) as t;
|
||||||
|
|
||||||
|
select count(id) into total
|
||||||
|
from citizen
|
||||||
|
where "search" is null or (
|
||||||
|
(name->'first_name')::text ilike '%'||"search"||'%' or
|
||||||
|
(name->'last_name')::text ilike '%'||"search"||'%'
|
||||||
|
);
|
||||||
end;
|
end;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user