Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/api/app/components/bs_request_state_badge_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def call

def decode_state_color
case state
when :review, :new
when 'review', 'new'
'secondary'
when :declined
when 'declined'
'danger'
when :superseded
when 'superseded'
'warning'
when :accepted
when 'accepted'
'success'
when :revoked
when 'revoked'
'dismissed'
else
'dark'
Expand All @@ -37,13 +37,13 @@ def decode_state_color

def decode_state_icon
case state
when :new
when 'new'
'code-branch'
when :review, :declined, :revoked
when 'review', 'declined', 'revoked'
'code-pull-request'
when :superseded
when 'superseded'
'code-compare'
when :accepted
when 'accepted'
'code-merge'
else
'code-fork'
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/components/request_decision_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def single_action_request
end

def confirmation
if @bs_request.state == :review
if @bs_request.status == :review
{ confirm: "Accept this request, despite the open reviews?\n\n#{@package_maintainers_hint}" }
else
{ confirm: 'Accept this request? This will commit the changes to the target!' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- name = "##{item.number} #{helpers.request_type_of_action(item)}"
.d-flex.flex-row.flex-wrap.align-items-baseline.collapsible-tooltip-parent
= link_to(request_show_path(item.number), class: 'text-word-break-all') do
= render BsRequestStateBadgeComponent.new(state: item.state)
= render BsRequestStateBadgeComponent.new(state: item.status)
= name
%i.fa.fa-question-circle.px-2.collapsible-tooltip{ title: 'Click to keep it open' }
= link_to('#', class: 'ms-auto',
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/concerns/webui/requests_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def filter_requests

def filter_states
@selected_filter['states'] = params[:states] if params[:states]&.compact_blank.present?
@bs_requests = @bs_requests.where(state: @selected_filter['states'])
@bs_requests = @bs_requests.where(status: @selected_filter['states'])
end

def filter_action_types
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def find_last_declined_bs_request

return if last_req.blank?

last_req.bs_request if bs_request.state == :declined
last_req.bs_request if bs_request.status == :declined
end

def get_diff(project, package, options = {})
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/projects/pulse_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def show
pulse = @project.project_log_entries.where(datetime: @date_range).order(datetime: :asc)

requests = @project.target_of_bs_requests.where(updated_at: @date_range).order(updated_at: :desc)
requests_by_state = requests.group(:state).count.sort_by { |_, v| -v }.to_h
requests_by_state = requests.group(:status).count.sort_by { |_, v| -v }.to_h
requests_by_percentage = requests_by_state.each_with_object({}) do |(k, v), hash|
hash[k] = (v * 100.0 / requests_by_state.values.sum).round.to_s
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/projects/status_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ def status_filter_packages
def status_gather_requests
# we do not filter requests for project because we need devel projects too later on and as long as the
# number of open requests is limited this is the easiest solution
raw_requests = BsRequest.order(:number).where(state: %i[new review declined]).joins(:bs_request_actions)
raw_requests = BsRequest.order(:number).where(status: %i[new review declined]).joins(:bs_request_actions)
.where(bs_request_actions: { type: %w[submit delete] }).pluck('bs_requests.number',
'bs_requests.state',
'bs_requests.status',
'bs_request_actions.target_project',
'bs_request_actions.target_package')

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def show
@is_author = @bs_request.creator == User.possibly_nobody.login

@is_target_maintainer = @bs_request.target_maintainer?(User.session)
@can_handle_request = @bs_request.state.in?(%i[new review declined]) && (@is_target_maintainer || @is_author)
@can_handle_request = @bs_request.status.in?(%w[new review declined]) && (@is_target_maintainer || @is_author)

@history = @bs_request.history_elements.includes(:user)

Expand All @@ -82,7 +82,7 @@ def show
reviews = @bs_request.reviews.where(state: 'new')
user = User.session # might be nil
@my_open_reviews = reviews.select { |review| review.matches_user?(user) }.reject(&:staging_project?)
@can_add_reviews = @bs_request.state.in?(%i[new review]) && (@is_author || @is_target_maintainer || @my_open_reviews.present?)
@can_add_reviews = @bs_request.status.in?(%w[new review]) && (@is_author || @is_target_maintainer || @my_open_reviews.present?)

respond_to do |format|
format.html
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/maintenance_incident_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def outgoing_request_links(requests)
safe_join(
[
link_to(request_show_path(request['number'])) do
tag.i(nil, class: "fas fa-flag pe-1 request-flag-#{request['state']}", title: "Release request in state '#{request['state']}'")
tag.i(nil, class: "fas fa-flag pe-1 request-flag-#{request['status']}", title: "Release request in state '#{request['status']}'")
end,
# rubocop:disable Rails/OutputSafety
TimeComponent.new(time: request.created_at).human_time.html_safe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def open_requests_count(project_name)
end

def relation
BsRequest.where(state: %i[new review declined])
BsRequest.where(status: %i[new review declined])
.joins(:bs_request_actions)
end
end
26 changes: 13 additions & 13 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BsRequest < ApplicationRecord

enum :status, VALID_REQUEST_STATES, instance_methods: false, scopes: false, validate: true

scope :to_accept_by_time, -> { where(state: %w[new review]).where(accept_at: ...Time.now) }
scope :to_accept_by_time, -> { where(status: %w[new review]).where(accept_at: ...Time.now) }

scope :with_action_types, lambda { |types|
includes(:bs_request_actions).where(bs_request_actions: { type: types }).distinct
Expand All @@ -51,7 +51,7 @@ class BsRequest < ApplicationRecord
)
}

scope :obsolete, -> { where(state: OBSOLETE_STATES) }
scope :obsolete, -> { where(status: OBSOLETE_STATES) }

has_many :bs_request_actions, dependent: :destroy
has_many :reviews, dependent: :delete_all
Expand Down Expand Up @@ -245,7 +245,7 @@ def self.sourcediff_has_shown_attribute?(sourcediff)
def as_json(*)
super(except: %i[state comment commenter]).tap do |request_hash|
request_hash['superseded_by_id'] = superseded_by if has_attribute?(:superseded_by)
request_hash['state'] = state.to_s if has_attribute?(:state)
request_hash['state'] = status if has_attribute?(:status)
request_hash['request_type'] = bs_request_actions.first.type
request_hash['package'] = bs_request_actions.first.target_package
request_hash['project'] = bs_request_actions.first.target_project
Expand Down Expand Up @@ -370,7 +370,7 @@ def render_xml(opts = {})
r.priority(priority) unless priority == 'moderate'

# state element
attributes = { name: state, who: commenter, when: updated_when.strftime('%Y-%m-%dT%H:%M:%S'), created: created_at.strftime('%Y-%m-%dT%H:%M:%S') }
attributes = { name: status, who: commenter, when: updated_when.strftime('%Y-%m-%dT%H:%M:%S'), created: created_at.strftime('%Y-%m-%dT%H:%M:%S') }
attributes[:superseded_by] = superseded_by if superseded_by
attributes[:approver] = approver if approver
r.state(attributes) do |s|
Expand Down Expand Up @@ -776,20 +776,20 @@ def setincident(incident)
end

def send_state_change
return unless state_changed?
return unless status_changed?
# new->review && review->new are not worth an event - it's just spam
return unless conclusive?

options = event_parameters

# measure duration unless superseding a final state, like revoked -> superseded
options[:duration] = (updated_at - created_at).to_i if FINAL_REQUEST_STATES.exclude?(state_was.to_sym) && FINAL_REQUEST_STATES.include?(state)
options[:duration] = (updated_at - created_at).to_i if FINAL_REQUEST_STATES.exclude?(status_was.to_sym) && FINAL_REQUEST_STATES.include?(status.to_sym)

Event::RequestStatechange.create(options)
end

def accept_staged_request
return if staging_project_id.nil? || state.to_sym != :accepted
return if staging_project_id.nil? || status.to_sym != :accepted

accepted_package = bs_request_actions.map(&:target_package)
staging_project.packages.where(name: accepted_package).destroy_all
Expand All @@ -800,13 +800,13 @@ def event_parameters
params = { id: id,
number: number,
description: description,
state: state,
state: status,
when: updated_when.strftime('%Y-%m-%dT%H:%M:%S'),
comment: comment,
author: creator,
namespace: namespace }

params[:oldstate] = state_was if state_changed?
params[:oldstate] = status_was if status_changed?
params[:who] = commenter if commenter.present?

# Use a nested data structure to support multiple actions in one request
Expand Down Expand Up @@ -845,10 +845,10 @@ def maintenance_release_request?
def auto_accept
# do not run for processed requests. Ignoring review on purpose since this
# must also work when people do not react anymore
return unless %i[new review].include?(state)
return unless %i[new review].include?(status.to_sym)

# use approve mechanic in case you want to wait for reviews
return if approver && state == :review
return if approver && status.to_sym == :review

return unless accept_at || approver

Expand Down Expand Up @@ -989,7 +989,7 @@ def staged_request?
def can_be_reopened?
(reviews.accepted.size + reviews.opened.size + reviews.declined.size).positive? &&
# Declined is not really a final state, since the request can always be reopened...
(BsRequest::FINAL_REQUEST_STATES.exclude?(state) || state == :declined)
(BsRequest::FINAL_REQUEST_STATES.exclude?(status.to_sym) || status.to_sym == :declined)
end

# Collects the embargo_date from all actions and returns...
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def reviews_reasons

# returns true if we have reached a state that we can't get out anymore
def conclusive?
FINAL_REQUEST_STATES.include?(state)
FINAL_REQUEST_STATES.include?(status.to_sym)
end

# [DEPRECATED] TODO: drop this after request_workflow_redesign beta is rolled_out
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/bs_request/find_for/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def all
@relation = @relation.where(creator: creator) if creator.present?
@relation = @relation.from_project_names(@parameters['project_name']).or(@relation.to_project_names(@parameters['project_name'])) if @parameters['project_name'].present?
@relation = @relation.with_action_types(types) if types.present?
@relation = @relation.where(state: states) if states.present?
@relation = @relation.where(status: states) if states.present?
@relation = @relation.where(priority: priorities) if priorities.present?
@relation = @relation.from_project(source_project_name) if source_project_name.present?
@relation = @relation.joins(:reviews).where('reviews.by_user IN (?) OR reviews.by_group IN (?)', reviewers, reviewers) if reviewers.present?
Expand Down
18 changes: 9 additions & 9 deletions src/api/app/models/bs_request_permission_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(request, options)
end

def cmd_addreview_permissions(permissions_granted)
raise ReviewChangeStateNoPermission, 'The request is not in state new or review' unless req.state.in?(%i[review new])
raise ReviewChangeStateNoPermission, 'The request is not in state new or review' unless req.status.in?(%w[review new])

req.bs_request_actions.each do |action|
set_permissions_for_action(action)
Expand All @@ -27,7 +27,7 @@ def cmd_addreview_permissions(permissions_granted)
end

def cmd_setpriority_permissions
raise SetPriorityNoPermission, 'The request is not in state new or review' unless req.state.in?(%i[review new])
raise SetPriorityNoPermission, 'The request is not in state new or review' unless req.status.in?(%w[review new])

return if req.creator == User.session!.login

Expand All @@ -40,7 +40,7 @@ def cmd_setpriority_permissions
end

def cmd_setincident_permissions
raise ReviewChangeStateNoPermission, 'The request is not in state new or review' unless req.state.in?(%i[review new])
raise ReviewChangeStateNoPermission, 'The request is not in state new or review' unless req.status.in?(%w[review new])

req.bs_request_actions.each do |action|
set_permissions_for_action(action)
Expand Down Expand Up @@ -68,7 +68,7 @@ def cmd_changereviewstate_permissions
# Admin always ...
return true if User.admin_session?

raise ReviewChangeStateNoPermission, 'The request is neither in state review nor new' unless req.state.in?(%i[review new])
raise ReviewChangeStateNoPermission, 'The request is neither in state review nor new' unless req.status.in?(%w[review new])
raise ReviewNotSpecified, 'The review must specified via by_user, by_group or by_project(by_package) argument.' unless by_user || by_group || by_package || by_project
raise ReviewChangeStateNoPermission, "review state change is not permitted for #{User.session!.login}" if by_user && User.session! != by_user
raise ReviewChangeStateNoPermission, "review state change for group #{by_group.title} is not permitted for #{User.session!.login}" if by_group && !User.session!.in_group?(by_group)
Expand All @@ -85,7 +85,7 @@ def cmd_changereviewstate_permissions

def cmd_changestate_permissions
# We do not support to revert changes from accepted requests (yet)
raise PostRequestNoPermission, 'change state from an accepted state is not allowed.' if req.state == :accepted
raise PostRequestNoPermission, 'change state from an accepted state is not allowed.' if req.status.to_sym == :accepted

# need to check for accept permissions
accept_check = opts[:newstate] == 'accepted'
Expand All @@ -98,15 +98,15 @@ def cmd_changestate_permissions
end
# Do not accept to skip the review, except force argument is given
if accept_check
if req.state == :review
if req.status.to_sym == :review
raise PostRequestNoPermission, 'Request is in review state. You may use the force parameter to ignore this.' unless opts[:force]
elsif req.state != :new
elsif req.status.to_sym != :new
raise PostRequestNoPermission, 'Request is not in new state. You may reopen it by setting it to new.'
end
end
# do not allow direct switches from a final state to another one to avoid races and double actions.
# request needs to get reopened first.
raise PostRequestNoPermission, "set state to #{opts[:newstate]} from a final state is not allowed." if req.state.in?(%i[accepted superseded revoked]) && opts[:newstate].in?(%w[accepted declined superseded revoked])
raise PostRequestNoPermission, "set state to #{opts[:newstate]} from a final state is not allowed." if req.status.in?(%w[accepted superseded revoked]) && opts[:newstate].in?(%w[accepted declined superseded revoked])

raise PostRequestMissingParameter, "Supersed a request requires a 'superseded_by' parameter with the request id." if opts[:newstate] == 'superseded' && !opts[:superseded_by]

Expand All @@ -133,7 +133,7 @@ def cmd_changestate_permissions
# NOTE: Staging managers should be able to repoen a request to unstage a declined request.
# The reason behind `user_is_staging_manager`, is that we need to manage reviews to send
# the request to the staging backlog.
(req.state == :declined && opts[:newstate].in?(%w[new review]) && (req.commenter == User.session!.login || user_is_staging_manager))
(req.status.to_sym == :declined && opts[:newstate].in?(%w[new review]) && (req.commenter == User.session!.login || user_is_staging_manager))

# permission and validation check for each action inside
req.bs_request_actions.each do |action|
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/models/concerns/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def classified_requests
requests = (requests_to_review | staged_requests.includes(:not_accepted_reviews, :bs_request_actions)).map do |request|
{
number: request.number,
state: request.state,
status: request.status,
package: request.first_target_package,
request_type: request.bs_request_actions.first.type,
missing_reviews: missing_reviews_for_classified_requests(request, request.not_accepted_reviews)
Expand All @@ -99,7 +99,7 @@ def untracked_requests
# The requests to review are requests which are not related to the staging project (unless they are also staged).
# They simply need a review from the maintainers of the staging project.
def requests_to_review
@requests_to_review ||= BsRequest.joins(:bs_request_actions).left_outer_joins(:reviews).where(state: :review, reviews: { by_project: name, state: :new })
@requests_to_review ||= BsRequest.joins(:bs_request_actions).left_outer_joins(:reviews).where(status: :review, reviews: { by_project: name, state: :new })
end

def building_repositories
Expand Down Expand Up @@ -271,7 +271,7 @@ def extract_missing_reviews(request, review)
end

def request_weight(request)
weight = if request[:state].in?(BsRequest::OBSOLETE_STATES) # obsolete
weight = if request[:status].in?(BsRequest::OBSOLETE_STATES) # obsolete
'0'
elsif request[:missing_reviews].present? # in review
'1'
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1152,24 +1152,24 @@ def open_requests
BsRequest.where(id: BsRequestAction.bs_request_ids_by_source_projects(name)).or(
BsRequest.where(id: Review.bs_request_ids_of_involved_projects(id))
)
).where(state: :review).distinct.pluck(:number)
).where(status: 'review').distinct.pluck(:number)

targets = BsRequest.joins(:bs_request_actions)
.to_project(name)
.or(BsRequest.from_project(name))
.where(state: :new)
.where(status: 'new')
.pluck(:number)

incidents = BsRequest.to_project(name)
.or(BsRequest.from_project(name))
.where(state: :new)
.where(status: 'new')
.with_action_types(:maintenance_incident)
.pluck(:number)

maintenance_release = if maintenance?
BsRequest.to_project("#{name}:%")
.or(BsRequest.from_project("#{name}:%"))
.where(state: :new)
.where(status: 'new')
.with_action_types(:maintenance_release)
.pluck(:number)
else
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/staging/staged_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def destroy
package_name: request.first_target_package
)

add_review_for_unstaged_request(request, staging_project) if request.state.in?(%i[new review declined])
add_review_for_unstaged_request(request, staging_project) if request.status.in?(%w[new review declined])
staging_project.staged_requests.delete(request)
end

Expand Down Expand Up @@ -117,7 +117,7 @@ def add_review_for_staged_request(request)

def add_review_for_unstaged_request(request, staging_project)
# request.addreview / request.change_review_state would also change the state of a declined request, avoid this.
if request.state == :declined
if request.status == 'declined'
request.reviews.create!(by_group: staging_workflow.managers_group.title, reason: "Being evaluated by group \"#{staging_workflow.managers_group}\"")
staging_project_review = request.reviews.find_by!(by_project: staging_project.name)
staging_project_review.update!(state: :accepted, reason: "Unstaged from project \"#{staging_project.name}\"")
Expand Down
Loading