Project

General

Profile

Delete journal entries in Database

Added by Moritz Koehler over 9 years ago

Hi community,

can you think of a good reason (Redmine stability standpoint) not to delete Journals in the Database. Since i have some calculated field and auto generated tables in long custom fields i get a messy history. I use the Custom workflow plugin to do it. Also i would use this plugin to delete the database entries. Here is my code to delete:

if @dojournal

jid = JournalDetail.last.journal_id
all_ids = JournalDetail.all.map(&:id)
count = all_ids.count-1

for i in count.downto(0)
  break if jid != JournalDetail.find(all_ids[i]).journal_id
  JournalDetail.find(all_ids[i]).destroy if  JournalDetail.find(all_ids[i]).prop_key.to_i == 3    
end
end

I works great but i'm a bit concerned if that would affect other parts of redmine on the long therm.

Thank you very much

If you have a better idea to control the journal creation of some custom fields i am very happy to learn about them :)

Regards

Moritz

Edit: after some testing, it does work for the Issue page but i still get the messy journal in my (first) email. I found that the email for changed issue get send form the Journal model when saving the issue. So the email gets send before the hock controller_issues_edit_after_save gets trigger by the custom workflow plugin.
Does anyone has an idea how to solve it without having to many changes in the source code?