Project

General

Profile

Feature #33296 » load_default_query.patch

Go MAEDA, 2020-04-19 06:20

View differences:

lib/redmine/default_data/loader.rb
31 31
          !Role.where(:builtin => 0).exists? &&
32 32
            !Tracker.exists? &&
33 33
            !IssueStatus.exists? &&
34
            !Enumeration.exists?
34
            !Enumeration.exists? &&
35
            !Query.exists?
35 36
        end
36 37

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

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

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

  
242
            # Project queries
243
            ProjectQuery.create!(
244
              :name => l(:label_my_projects),
245
              :filters =>
246
                {
247
                  'status' => {:operator => '=', :values => ['1']},
248
                  'id' => {:operator=>'=', :values=>['mine']}
249
                },
250
              :visibility => Query::VISIBILITY_PUBLIC
251
            )
252
            ProjectQuery.create!(
253
              :name => l(:label_my_bookmarks),
254
              :filters =>
255
                {
256
                  'status' => {:operator => '=', :values => ['1']},
257
                  'id' => {:operator => '=', :values => ['bookmarks']}
258
                },
259
              :visibility => Query::VISIBILITY_PUBLIC
260
            )
261

  
262
            # Time entry queries
263
            TimeEntryQuery.create!(
264
              :name => l(:label_spent_time),
265
              :filters =>
266
                {
267
                  'spent_on' => {:operator => '*', :values => ['']},
268
                  'user_id' =>{:operator => '=', :values => ['me']}
269
                },
270
                :sort_criteria => [['spent_on', 'desc']],
271
                :options => {:totalable_names => [:hours]},
272
                :visibility => Query::VISIBILITY_PUBLIC
273
            )
194 274
          end
195 275
          true
196 276
        end
(5-5/5)