-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from centosadmin/develop
Release 0.2.0
- Loading branch information
Showing
14 changed files
with
110 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# 0.2.0 | ||
|
||
* Add issue open time to user account options | ||
* Add sidekiq-cron support | ||
|
||
# 0.1.3 | ||
|
||
* Use datetime for reopen schedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
<% if User.current.allowed_to?(:edit_issues, @project) && | ||
Setting.plugin_redmine_issue_open_date['freezed_statuses'].include?(issue.status_id.to_s) %> | ||
<style type="text/css"> | ||
#open_date_area select { | ||
width: auto; | ||
} | ||
</style> | ||
|
||
<p id="open_date_area"> | ||
<%= form.label :open_date %> | ||
<% current_time = Time.now %> | ||
<%= form.datetime_select :open_date, default: current_time - (current_time.min % 5).minutes, minute_step: 5 %> | ||
<span style="display: inline-block;"> | ||
<%= form.date_select :open_date, default: User.current.issue_open_time , minute_step: 5 %> | ||
</span> | ||
<span style="display: inline-block;"> | ||
<%= form.time_select :open_date, default: User.current.issue_open_time , minute_step: 5, ignore_date: true %> | ||
</span> | ||
</p> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<p> | ||
<%= label :user, :issue_open_time, l(:field_issue_open_time) %> | ||
<%= form.time_select :issue_open_time, { minute_step: 5, include_blank: true }, style: 'width: auto' %> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class IssueOpenWorker | ||
include Sidekiq::Worker if Gem.loaded_specs.key?('sidekiq') | ||
|
||
def perform | ||
log = Rails.env.production? ? Logger.new(Rails.root.join('log/issue_open_date', 'switch-task.log')) : Logger.new(STDOUT) | ||
|
||
freezed_status_ids = Setting.plugin_redmine_issue_open_date['freezed_statuses'] || [] | ||
open_status_id = Setting.plugin_redmine_issue_open_date['open_status'] | ||
|
||
Issue.where('status_id IN(?) AND open_date <= ?', freezed_status_ids, Time.now).find_each do |issue| | ||
log.debug issue.inspect | ||
issue.init_journal(User.anonymous) | ||
issue.status_id = open_status_id | ||
issue.open_date = nil | ||
issue.save | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddIssueOpenTimeToUsers < ActiveRecord::Migration | ||
def change | ||
add_column :users, :issue_open_time, :time | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
User.send(:include, | ||
Module.new do | ||
def self.included(base) | ||
(1..5).each { |i| base.send(:safe_attributes, "issue_open_time(#{i}i)") } | ||
end | ||
end | ||
) | ||
|
||
User.send(:prepend, | ||
Module.new do | ||
def issue_open_time | ||
time = | ||
begin | ||
tomorrow = Date.tomorrow | ||
super ? super.change(year: tomorrow.year, month: tomorrow.month, day: tomorrow.day) : tomorrow.to_time | ||
end | ||
time_zone ? time.to_datetime.change(offset: time_zone.formatted_offset) : time.to_datetime | ||
end | ||
end | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
namespace :issue_open_date do | ||
task :switch => :environment do | ||
log = Rails.env.production? ? Logger.new(Rails.root.join('log/issue_open_date', 'switch-task.log')) : Logger.new(STDOUT) | ||
|
||
freezed_status_ids = Setting.plugin_redmine_issue_open_date['freezed_statuses'] || [] | ||
open_status_id = Setting.plugin_redmine_issue_open_date['open_status'] | ||
IssueOpenWorker.new.perform | ||
end | ||
|
||
Issue.where('status_id IN(?) AND open_date <= ?', freezed_status_ids, Time.now).find_each do |issue| | ||
log.debug issue.inspect | ||
issue.init_journal(User.current) | ||
issue.status_id = open_status_id | ||
issue.open_date = nil | ||
issue.save | ||
namespace :sidekiq do | ||
task init: :environment do | ||
unless Gem.loaded_specs.key?('sidekiq-cron') | ||
puts 'sidekiq-cron not found!' | ||
next | ||
end | ||
Sidekiq::Cron::Job.create(name: 'issue_open_job', cron: '*/5 * * * *', class: 'IssueOpenWorker') | ||
end | ||
|
||
end | ||
end |