Module: Snippets

Defined in:
app/services/snippets/count_service.rb,
app/services/snippets/base_service.rb,
app/services/snippets/create_service.rb,
app/services/snippets/update_service.rb,
app/services/snippets/destroy_service.rb,
app/services/snippets/bulk_destroy_service.rb,
app/services/snippets/update_statistics_service.rb,
app/services/snippets/repository_validation_service.rb

Overview

Service for calculating visible Snippet counts via one query for the given user or project.

Authorisation level checks will be included, ensuring the correct counts will be returned for the given user (if any).

Basic usage:

user = User.find(1)

Snippets::CountService.new(user, author: user).execute
#=> {
  are_public: 1,
  are_internal: 1,
  are_private: 1,
  all: 3
}

Counts can be scoped to a project:

user = User.find(1)
project = Project.find(1)

Snippets::CountService.new(user, project: project).execute
#=> {
  are_public: 1,
  are_internal: 1,
  are_private: 0,
  all: 2
}

Either a project or an author must be supplied.

Defined Under Namespace

Modules: BlobsActions, SendBlob Classes: ApplicationController, BaseService, BlobsController, BulkDestroyService, CountService, CreateService, DestroyService, NotesController, RepositoryValidationService, UpdateService, UpdateStatisticsService