Skip to content

Commit

Permalink
Permite filtrar por entidad como subestructura de. Closes #248
Browse files Browse the repository at this point in the history
  • Loading branch information
vtamara committed Dec 8, 2023
1 parent aef12cc commit d410046
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
9 changes: 7 additions & 2 deletions app/models/consaportante.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ class Consaportante < ActiveRecord::Base
where("unaccent(ultimo_celular_trabajo) ILIKE '%' || unaccent(?) || '%'", c)
}

scope :filtro_ultima_entidad_nombre, lambda { |e|
where("unaccent(ultima_entidad_nombre) ILIKE '%' || unaccent(?) || '%'", e)
#scope :filtro_ultima_entidad_nombre, lambda { |e|
# where("unaccent(ultima_entidad_nombre) ILIKE '%' || unaccent(?) || '%'", e)
#}

scope :filtro_ultima_entidad_nombre, lambda { |id|
where("ultima_entidad_id IN "\
"(select entidadessubde(?))", id)
}

scope :filtro_ultimo_cargoestado, lambda { |cid|
Expand Down
17 changes: 12 additions & 5 deletions app/views/consaportantes/_filtro_ultima_entidad_nombre.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<%= f.input :busultima_entidad_nombre,
label: false,
<%= f.input :busultima_entidad_nombre,
collection: Msip::Orgsocial.where(
"id IN (SELECT DISTINCT subde_id FROM msip_orgsocial "\
" WHERE subde_id IS NOT NULL)"
),
label: false,
include_blank: true,
label_method: :presenta_nombre,
value_method: :id,
selected: Msip::ModeloHelper.poromision(params, :busultima_entidad_nombre),
input_html: {
value: Msip::ModeloHelper::poromision(params, :busultima_entidad_nombre),
style: "min-width: 4em",
"data-enviarautomatico": ""
class: 'chosen-select',
'data-enviarautomatico' => ''
}
%>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Entidad subestructura de
Entidad como subestructura de
30 changes: 29 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--

-- *not* creating schema, since initdb creates it


--
-- Name: es_co_utf_8; Type: COLLATION; Schema: public; Owner: -
--
Expand Down Expand Up @@ -263,6 +270,26 @@ BEGIN
END;$$;


--
-- Name: entidadessubde(numeric); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.entidadessubde(entidad_id numeric) RETURNS SETOF numeric
LANGUAGE sql
AS $$
WITH RECURSIVE supjer AS (
SELECT o1.id, g1.nombre, o1.subde_id
FROM msip_orgsocial AS o1
JOIN msip_grupoper AS g1 ON g1.id=o1.grupoper_id
WHERE o1.id=entidad_id
UNION SELECT o2.id, g2.nombre, o2.subde_id
FROM msip_orgsocial AS o2
JOIN msip_grupoper AS g2 ON g2.id=o2.grupoper_id
INNER JOIN supjer AS s ON o2.subde_id=s.id)
SELECT id FROM supjer;
$$;


--
-- Name: entidadessup(numeric); Type: FUNCTION; Schema: public; Owner: -
--
Expand Down Expand Up @@ -13044,6 +13071,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20231205202418'),
('20231205205549'),
('20231205205600'),
('20231208162022');
('20231208162022'),
('20231208203424');


0 comments on commit d410046

Please sign in to comment.