Loading app/controllers/api/agents_controller.rb +12 −0 Original line number Diff line number Diff line Loading @@ -30,7 +30,19 @@ class Api::AgentsController < ApplicationController # Devuelve la informacion basica del agente 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 private Loading app/views/api/agents/by_year.rabl 0 → 100644 +22 −0 Original line number Diff line number Diff line 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 app/views/api/agents/show.rabl 0 → 100644 +52 −0 Original line number Diff line number Diff line 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 app/views/api/projects/show.rabl +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ attributes fecha_fin_aprobada_original: :original_approved_ending_date attributes fecha_inicio_actividades: :activities_starting_date attributes fecha_fin_actividades: :activities_ending_date attributes fecha_de_inicio: :starting_date attributes fecha_de_inicio: :ending_date attributes fecha_de_fin: :ending_date attributes duracion_meses: :duration node :status do Loading config/routes.rb +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ Gor::Application.routes.draw do get '/project/:id/matrix' => "projects#matrix" get '/project/:id/expenses' => "projects#expenses" get '/agent/:id' => "agents#show" get '/agent/:id/year/:year' => "agents#by_year" end root :to => 'usuario#entrada', :seccion => "entrada" Loading Loading
app/controllers/api/agents_controller.rb +12 −0 Original line number Diff line number Diff line Loading @@ -30,7 +30,19 @@ class Api::AgentsController < ApplicationController # Devuelve la informacion basica del agente 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 private Loading
app/views/api/agents/by_year.rabl 0 → 100644 +22 −0 Original line number Diff line number Diff line 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
app/views/api/agents/show.rabl 0 → 100644 +52 −0 Original line number Diff line number Diff line 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
app/views/api/projects/show.rabl +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ attributes fecha_fin_aprobada_original: :original_approved_ending_date attributes fecha_inicio_actividades: :activities_starting_date attributes fecha_fin_actividades: :activities_ending_date attributes fecha_de_inicio: :starting_date attributes fecha_de_inicio: :ending_date attributes fecha_de_fin: :ending_date attributes duracion_meses: :duration node :status do Loading
config/routes.rb +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ Gor::Application.routes.draw do get '/project/:id/matrix' => "projects#matrix" get '/project/:id/expenses' => "projects#expenses" get '/agent/:id' => "agents#show" get '/agent/:id/year/:year' => "agents#by_year" end root :to => 'usuario#entrada', :seccion => "entrada" Loading