From e739eb036df23db4a03681190bf07ba0b8f1302c Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 15:23:20 +0200 Subject: Move participants method to shared Participable concern. --- app/models/snippet.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'app/models/snippet.rb') diff --git a/app/models/snippet.rb b/app/models/snippet.rb index c11c28805eb..d2af26539b6 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -19,6 +19,7 @@ class Snippet < ActiveRecord::Base include Sortable include Linguist::BlobHelper include Gitlab::VisibilityLevel + include Participable default_value_for :visibility_level, Snippet::PRIVATE @@ -47,6 +48,8 @@ class Snippet < ActiveRecord::Base scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) } + participant :author, :notes + def self.content_types [ ".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java", @@ -87,18 +90,6 @@ class Snippet < ActiveRecord::Base visibility_level end - def participants(current_user = self.author) - users = [] - users << author - - notes.each do |note| - users << note.author - users.push *note.mentioned_users(current_user) - end - - users.uniq - end - class << self def search(query) where('(title LIKE :query OR file_name LIKE :query)', query: "%#{query}%") -- cgit v1.2.1