Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 491
- Log:
Jan 2024 bug tracker updates
- Author:
- rool
- Date:
- Sun Jan 28 09:33:07 +0000 2024
- Size:
- 2224 Bytes
1 | class TicketChange < ActiveRecord::Base |
2 | belongs_to :ticket |
3 | serialize :log |
4 | |
5 | def each_log |
6 | return unless self.log |
7 | self.log.each do |name, (old_value, new_value)| |
8 | yield [name, old_value, new_value] |
9 | end |
10 | end |
11 | |
12 | def empty? |
13 | return false if self.comment && !self.comment.empty? |
14 | return false if self.log && !self.log.empty? |
15 | return false if self.attachment && !self.attachment.empty? |
16 | true |
17 | end |
18 | |
19 | # TODO: flesh out |
20 | def attach(attachment) |
21 | unless attachment.blank? |
22 | self.attachment = base_part_of(attachment.original_filename) |
23 | self.content_type = attachment.content_type.strip |
24 | self.attachment_fsname = dump_filename |
25 | filename = dump_filename |
26 | attachment.rewind |
27 | File.open(filename, "wb") do |f| |
28 | f.write(attachment.read) |
29 | end |
30 | end |
31 | end |
32 | |
33 | def dump_filename |
34 | File.expand_path(File.join(ATTACHMENTS_PATH, "#{self.id}-#{self.attachment}")) |
35 | end |
36 | |
37 | def has_attachment? |
38 | self.attachment && !self.attachment.empty? |
39 | end |
40 | |
41 | class << self |
42 | # Returns am array of "normalized" hashes, useful for mixing display of search result from |
43 | # other resources (token finder code based on things found in Typo) |
44 | def search(query) |
45 | if !query.to_s.strip.empty? |
46 | tokens = query.split.collect {|c| "%#{c.downcase}%"} |
47 | findings = find( :all, |
48 | :conditions => [(["(LOWER(comment) LIKE ?)"] * tokens.size).join(" AND "), |
49 | *tokens.collect { |token| [token] }.flatten], |
50 | :order => 'created_at DESC') |
51 | findings.collect do |f| |
52 | { |
53 | :title => "Ticket ##{f.ticket_id} comment by #{f.author}", |
54 | :content => f.comment, |
55 | :link => { :controller => '/tickets', :action => 'show', :id => f.ticket_id }, |
56 | :status => (f.ticket.status.name rescue 'Unknown') |
57 | } |
58 | end |
59 | else |
60 | [] |
61 | end |
62 | end |
63 | end |
64 | |
65 | protected |
66 | validates_presence_of :author |
67 | |
68 | private |
69 | def base_part_of(filename) |
70 | filename = File.basename(filename.strip) |
71 | # remove leading period, whitespace and \ / : * ? " ' < > | |
72 | filename = filename.gsub(%r{^\.|[\s/\\\*\:\?'"<>\|]}, '_') |
73 | end |
74 | |
75 | end |