Class: DesignManagement::GenerateImageVersionsService

Inherits:
DesignService show all
Defined in:
app/services/design_management/generate_image_versions_service.rb

Overview

This service generates smaller image versions for `DesignManagement::Design` records within a given `DesignManagement::Version`.

Constant Summary collapse

MAX_DESIGN_SIZE =

We limit processing to only designs with file sizes that don't exceed `MAX_DESIGN_SIZE`.

Note, we may be able to remove checking this limit, if when we come to implement a file size limit for designs, there are no designs that exceed 40MB on GitLab.com

See gitlab.com/gitlab-org/gitlab/-/merge_requests/22860#note_281780387

40.megabytes.freeze

Instance Attribute Summary

Attributes inherited from DesignService

#issue

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from DesignService

#collection, #project, #repository, #target_branch

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(version) ⇒ GenerateImageVersionsService

Returns a new instance of GenerateImageVersionsService.


17
18
19
20
21
# File 'app/services/design_management/generate_image_versions_service.rb', line 17

def initialize(version)
  super(version.project, version.author, issue: version.issue)

  @version = version
end

Instance Method Details

#executeObject


23
24
25
26
27
28
29
30
31
# File 'app/services/design_management/generate_image_versions_service.rb', line 23

def execute
  # rubocop: disable CodeReuse/ActiveRecord
  version.actions.includes(:design).each do |action|
    generate_image(action)
  end
  # rubocop: enable CodeReuse/ActiveRecord

  success(version: version)
end