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
|
||||
|
||||
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)
|
||||
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}
|
||||
@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
|
||||
@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}
|
||||
|
||||
rd: run-docker
|
||||
|
||||
@@ -9,8 +9,7 @@ create or replace function find_citizens(
|
||||
) language plpgsql as
|
||||
$$
|
||||
begin
|
||||
select json_agg(t), (select count(id) from citizen)
|
||||
into resource, total
|
||||
select json_agg(t) into resource
|
||||
from (
|
||||
select
|
||||
z.*,
|
||||
@@ -38,6 +37,13 @@ begin
|
||||
z.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
) 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;
|
||||
$$;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user