load_default_query.patch

Go MAEDA, 2020-04-16 13:38

Download (2.98 KB)

View differences:

lib/redmine/default_data/loader.rb
23 23

  
24 24
    module Loader
25 25
      include Redmine::I18n
26

  
27 26
      class << self
28 27
        # Returns true if no data is already loaded in the database
29 28
        # otherwise false
......
31 30
          !Role.where(:builtin => 0).exists? &&
32 31
            !Tracker.exists? &&
33 32
            !IssueStatus.exists? &&
34
            !Enumeration.exists?
33
            !Enumeration.exists? &&
34
            !IssueQuery.exists?
35 35
        end
36 36

  
37 37
        # Loads the default data
......
191 191

  
192 192
            TimeEntryActivity.create!(:name => l(:default_activity_design), :position => 1)
193 193
            TimeEntryActivity.create!(:name => l(:default_activity_development), :position => 2)
194

  
195
            # Queries
196
            IssueQuery.create!(
197
              :name => l(:label_assigned_to_me_issues),
198
              :filters =>
199
                {
200
                  'status_id' => {:operator => 'o', :values => ['']},
201
                  'assigned_to_id' => {:operator => '=', :values => ['me']},
202
                  'project.status' => {:operator => '=', :values => ['1']}
203
                },
204
              :sort_criteria => [['priority', 'desc'], ['updated_on', 'desc']],
205
              :visibility => IssueQuery::VISIBILITY_PUBLIC
206
            )
207
            IssueQuery.create!(
208
              :name => l(:label_reported_issues),
209
              :filters =>
210
                {
211
                  'status_id' => {:operator => 'o', :values => ['']},
212
                  'author_id' => {:operator => '=', :values => ['me']},
213
                  'project.status' => {:operator => '=', :values => ['1']}
214
                },
215
              :sort_criteria => [['updated_on', 'desc']],
216
              :visibility => IssueQuery::VISIBILITY_PUBLIC
217
            )
218
            IssueQuery.create!(
219
              :name => l(:label_updated_issues),
220
              :filters =>
221
                {
222
                  'status_id' => {:operator => 'o', :values => ['']},
223
                  'updated_by' => {:operator => '=', :values => ['me']},
224
                  'project.status' => {:operator => '=', :values => ['1']}
225
                },
226
              :sort_criteria => [['updated_on', 'desc']],
227
              :visibility => IssueQuery::VISIBILITY_PUBLIC
228
            )
229
            IssueQuery.create!(
230
              :name => l(:label_watched_issues),
231
              :filters =>
232
                {
233
                  'status_id' => {:operator => 'o', :values => ['']},
234
                  'watcher_id' => {:operator => '=', :values => ['me']},
235
                  'project.status' => {:operator => '=', :values => ['1']},
236
                },
237
              :sort_criteria => [['updated_on', 'desc']],
238
              :visibility => IssueQuery::VISIBILITY_PUBLIC
239
            )
194 240
          end
195 241
          true
196 242
        end