diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-03-28 14:56:30 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-03-28 14:56:30 +0200 |
commit | d3e794e26f806fe491269a74e76c39669433c0fe (patch) | |
tree | e094ecabf28df0007325a524980a0c0b22a840cb /app/controllers | |
parent | 73203873438d666427228ffdbfe835ea4ffddaa6 (diff) | |
download | gitlab-ce-d3e794e26f806fe491269a74e76c39669433c0fe.tar.gz |
Optionally filter by deployment time
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/deployments_controller.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb index ed0f802dbd9..a8a6f09d9df 100644 --- a/app/controllers/projects/deployments_controller.rb +++ b/app/controllers/projects/deployments_controller.rb @@ -2,9 +2,11 @@ class Projects::DeploymentsController < Projects::ApplicationController before_action :authorize_read_deployment! def index - serializer = DeploymentSerializer.new(user: @current_user) - deployments = environment.deployments.where('created_at > ?', 8.hours.ago) - .map { |d| serializer.represent(d) } + serializer = DeploymentSerializer.new(user: @current_user, project: project) + + deployments = environment.deployments.reorder(created_at: :desc) + deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time + deployments = deployments.map { |deployment| serializer.represent(deployment) } render json: { deployments: deployments } end |