-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathissue_patch.rb
More file actions
105 lines (81 loc) · 2.57 KB
/
Copy pathissue_patch.rb
File metadata and controls
105 lines (81 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
require_dependency 'issue'
# :nodoc:
module RedmineRedsun
# Patches Redmine's Issue dynamically.
module IssuePatch
def self.included(base) # :nodoc:
base.extend ClassMethods
base.send(:include, InstanceMethods)
# Same as typing in the class
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
searchable do
# Class Name
string :class_name, stored: true
# Issue ID
text :id, stored: true
# Tracker
integer :tracker_id, references: Tracker
# Active?
boolean :active, stored: true do
active?
end
# is_private
boolean :is_private, stored: true
# Subject
text :subject, stored: true do
subject.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if subject.present?
end
# Description
text :description, stored: true do
description.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if description.present?
end
# Project ID
integer :project_id
# Journals entries, i.e. status updates, comments, etc.
text :comments, stored: true do
journals.where("journals.notes != ''").map { |j| j.notes.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if j.notes.present? }.join(' ')
end
# Updated at
time :updated_on, trie: true
# Created at
time :created_on, trie: true
# Issue creator
integer :author_id, references: User
# Status
integer :status_id, references: IssueStatus
# Start
time :start_date, trie: true
# Stop
time :due_date, trie: true
# Priority
integer :priority_id, references: IssuePriority
# Assigned to
integer :assigned_to_id, references: User
# Category
integer :category_id, references: IssueCategory
# Name of Project
string :project_name, stored: true
end
end
end
# :nodoc:
module ClassMethods
end
# :nodoc:
module InstanceMethods
SORT_FIELDS = %w(updated_on created_on score)
SORT_ORDER = [%w(ASC label_ascending), %w(DESC label_descending)]
def class_name
self.class.name
end
def project_name
project.name if project
end
def active?
return false if project.nil?
project.active?
end
end
end
end