Skip to content
Snippets Groups Projects
Commit 3d62e8f0 authored by Santiago Ramos's avatar Santiago Ramos
Browse files

Ticket #3974 . Info de agentes en el api del CM

parent 6355b224
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,19 @@ class Api::AgentsController < ApplicationController ...@@ -30,7 +30,19 @@ class Api::AgentsController < ApplicationController
# Devuelve la informacion basica del agente # Devuelve la informacion basica del agente
def show def show
@proyectos_abiertos = @agente.proyecto_implementador.joins(:definicion_estado).
where("definicion_estado.cerrado" => false)
@datos_agente = @agente.dato_agente.where(etapa_id: nil)
end
# Devuelve la informacion asociada a la etapa definida por año enviado
def by_year
@etapa = @agente.etapa.where("fecha_inicio <= ?", Date.new(params[:year].to_i)).order(:fecha_inicio).last
if @etapa
@datos_agente = @agente.dato_agente.where(etapa_id: @etapa)
else
head :not_found
end
end end
private private
......
object false
node :period_name do
@etapa.nombre
end
node :period_from do
@etapa.fecha_inicio
end
node :period_to do
@etapa.fecha_fin
end
child @datos_agente, root: :agent_data, object_root: false do
node :code do |d|
d.definicion_dato_agente.nombre
end
node :value do |d|
d.valor
end
end
object @agente => :agent
attributes nombre: :name, nombre_completo: :full_name, nif: :id_number
node :currency do
{ abbr: @agente.moneda_principal.abreviatura, name: @agente.moneda_principal.nombre }
end
node :foreign_currency do
{ abbr: @agente.moneda_intermedia.abreviatura, name: @agente.moneda_intermedia.nombre }
end
node :country do
{ abbr: @agente.pais.codigo, name: @agente.pais.nombre }
end
child TipoConvocatoria.all, root: :projects_by_types, object_root: false do
node :code do |cat|
cat.nombre.parameterize
end
node :quantity do |cat|
@proyectos_abiertos.joins(:convocatoria).
where("convocatoria.tipo_convocatoria_id" => cat.id).
count
end
end
node :projects_by_status do
{ open: @proyectos_abiertos.count,
formulation: @proyectos_abiertos.where("definicion_estado.aprobado" => false).count,
execution: @proyectos_abiertos.where("definicion_estado.aprobado" => true, "definicion_estado.reporte" => false).count,
reporting: @proyectos_abiertos.where("definicion_estado.aprobado" => true, "definicion_estado.reporte" => true).count }
end
child CategoriaAreaActuacion.all, root: :projects_by_area_types, object_root: false do
node :code do |cat|
cat.nombre.parameterize
end
node :quantity do |cat|
@proyectos_abiertos.joins(:area_actuacion).
where("area_actuacion.categoria_area_actuacion_id" => cat.id).
count
end
end
child @datos_agente, root: :agent_data, object_root: false do
node :code do |d|
d.definicion_dato_agente.nombre
end
node :value do |d|
d.valor
end
end
...@@ -7,7 +7,7 @@ attributes fecha_fin_aprobada_original: :original_approved_ending_date ...@@ -7,7 +7,7 @@ attributes fecha_fin_aprobada_original: :original_approved_ending_date
attributes fecha_inicio_actividades: :activities_starting_date attributes fecha_inicio_actividades: :activities_starting_date
attributes fecha_fin_actividades: :activities_ending_date attributes fecha_fin_actividades: :activities_ending_date
attributes fecha_de_inicio: :starting_date attributes fecha_de_inicio: :starting_date
attributes fecha_de_inicio: :ending_date attributes fecha_de_fin: :ending_date
attributes duracion_meses: :duration attributes duracion_meses: :duration
node :status do node :status do
......
...@@ -12,6 +12,7 @@ Gor::Application.routes.draw do ...@@ -12,6 +12,7 @@ Gor::Application.routes.draw do
get '/project/:id/matrix' => "projects#matrix" get '/project/:id/matrix' => "projects#matrix"
get '/project/:id/expenses' => "projects#expenses" get '/project/:id/expenses' => "projects#expenses"
get '/agent/:id' => "agents#show" get '/agent/:id' => "agents#show"
get '/agent/:id/year/:year' => "agents#by_year"
end end
root :to => 'usuario#entrada', :seccion => "entrada" root :to => 'usuario#entrada', :seccion => "entrada"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment