[PROJXP [PATCH] Emails are sent when no activity is recorded. #10
by Benjamin LAN-SUN-LUK
From: Benjamin LAN-SUN-LUK <benjamin.lan-sun-luk(a)supinfo.com>
Signed-off-by: Benjamin <benjamin.lan-sun-luk(a)supinfo.com>
---
app/models/user_mailer.rb | 10 +++++
.../user_mailer/no_activity_recorded.html.erb | 6 +++
config/environment.rb | 5 ++-
config/initializers/schedules.rb | 37 ++++++++++++++++++++
4 files changed, 57 insertions(+), 1 deletions(-)
create mode 100644 app/views/user_mailer/no_activity_recorded.html.erb
create mode 100644 config/initializers/schedules.rb
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index 73308af..8d60671 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -7,4 +7,14 @@ class UserMailer < ActionMailer::Base
subject "Your password"
body :user => user, :new_password => new_password
end
+
+ # Send an e-mail to an user an notify him that no-activity has been detected
+ # for some backlog items.
+ #
+ def no_activity_recorded(user, backlog_items)
+ recipients user.email
+ from "no_reply(a)projxp.org" # TODO Email must be edit
+ subject "No activity has been detected"
+ body :user => user, :backlog_items => backlog_items
+ end
end
diff --git a/app/views/user_mailer/no_activity_recorded.html.erb b/app/views/user_mailer/no_activity_recorded.html.erb
new file mode 100644
index 0000000..e4acd3c
--- /dev/null
+++ b/app/views/user_mailer/no_activity_recorded.html.erb
@@ -0,0 +1,6 @@
+Dear <%= @user.display_name %>,
+
+No activities was detected on this backlogs:
+<% @backlog_items.each do |backlog_item|%>
+<%= backlog_item.user_story.title %>
+<% end %>
diff --git a/config/environment.rb b/config/environment.rb
index af8a593..1687102 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -72,6 +72,9 @@ Rails::Initializer.run do |config|
# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc
+
+ # Gems
+ config.gem 'openwferu-scheduler', :lib => 'openwfe/util/scheduler'
end
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
@@ -82,7 +85,7 @@ ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
# Mail configuration.
# Please complete the config file are locate at /config/mailer.yml
-#
+#
require "smtp_tls"
mailer_config = File.open("#{RAILS_ROOT}/config/mailer.yml")
diff --git a/config/initializers/schedules.rb b/config/initializers/schedules.rb
new file mode 100644
index 0000000..287756c
--- /dev/null
+++ b/config/initializers/schedules.rb
@@ -0,0 +1,37 @@
+require 'fastthread'
+require 'openwfe/util/scheduler'
+include OpenWFE
+
+# Initialize a threads array
+threads = []
+
+threads << Thread.new do
+ scheduler = Scheduler.new
+ scheduler.start
+
+ # Do this everyday at 10:00 am
+ scheduler.schedule('0 8 * * *') do
+
+ user_no_activity_on_backlog_items = {}
+ BacklogItem.find_all_by_state(BacklogItem::STATE_ASSIGNED).each do |backlog_item|
+ backlog_item.tasks.each do |task|
+ if task.created_at.to_date < Date.yesterday
+ backlog_item_owner = backlog_item.owner
+ user_no_activity_on_backlog_items[backlog_item_owner] ||= []
+ user_no_activity_on_backlog_items[backlog_item_owner] << backlog_item
+ end
+ end
+ end
+
+ # Send the e-mail
+ user_no_activity_on_backlog_items.each do |owner, backlog_items|
+ UserMailer.deliver_no_activity_recorded(owner, backlog_items)
+ end
+
+ end
+
+ scheduler.join
+end
+
+# Run all threads
+threads.each { |thread| thread.run }
\ No newline at end of file
--
1.5.2.4
15 years, 5 months
[PROJXP [PATCH] Emails are sent when no activity is recorded. #10
by Benjamin LAN-SUN-LUK
From: Benjamin LAN-SUN-LUK <benjamin.lan-sun-luk(a)supinfo.com>
Signed-off-by: Benjamin <benjamin.lan-sun-luk(a)supinfo.com>
---
app/models/user_mailer.rb | 10 +++++
.../user_mailer/no_activity_recorded.html.erb | 6 +++
config/environment.rb | 5 ++-
config/initializers/schedules.rb | 37 ++++++++++++++++++++
4 files changed, 57 insertions(+), 1 deletions(-)
create mode 100644 app/views/user_mailer/no_activity_recorded.html.erb
create mode 100644 config/initializers/schedules.rb
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index 73308af..8d60671 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -7,4 +7,14 @@ class UserMailer < ActionMailer::Base
subject "Your password"
body :user => user, :new_password => new_password
end
+
+ # Send an e-mail to an user an notify him that no-activity has been detected
+ # for some backlog items.
+ #
+ def no_activity_recorded(user, backlog_items)
+ recipients user.email
+ from "no_reply(a)projxp.org" # TODO Email must be edit
+ subject "No activity has been detected"
+ body :user => user, :backlog_items => backlog_items
+ end
end
diff --git a/app/views/user_mailer/no_activity_recorded.html.erb b/app/views/user_mailer/no_activity_recorded.html.erb
new file mode 100644
index 0000000..e4acd3c
--- /dev/null
+++ b/app/views/user_mailer/no_activity_recorded.html.erb
@@ -0,0 +1,6 @@
+Dear <%= @user.display_name %>,
+
+No activities was detected on this backlogs:
+<% @backlog_items.each do |backlog_item|%>
+<%= backlog_item.user_story.title %>
+<% end %>
diff --git a/config/environment.rb b/config/environment.rb
index af8a593..1687102 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -72,6 +72,9 @@ Rails::Initializer.run do |config|
# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc
+
+ # Gems
+ config.gem 'openwferu-scheduler', :lib => 'openwfe/util/scheduler'
end
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
@@ -82,7 +85,7 @@ ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
# Mail configuration.
# Please complete the config file are locate at /config/mailer.yml
-#
+#
require "smtp_tls"
mailer_config = File.open("#{RAILS_ROOT}/config/mailer.yml")
diff --git a/config/initializers/schedules.rb b/config/initializers/schedules.rb
new file mode 100644
index 0000000..287756c
--- /dev/null
+++ b/config/initializers/schedules.rb
@@ -0,0 +1,37 @@
+require 'fastthread'
+require 'openwfe/util/scheduler'
+include OpenWFE
+
+# Initialize a threads array
+threads = []
+
+threads << Thread.new do
+ scheduler = Scheduler.new
+ scheduler.start
+
+ # Do this everyday at 10:00 am
+ scheduler.schedule('0 8 * * *') do
+
+ user_no_activity_on_backlog_items = {}
+ BacklogItem.find_all_by_state(BacklogItem::STATE_ASSIGNED).each do |backlog_item|
+ backlog_item.tasks.each do |task|
+ if task.created_at.to_date < Date.yesterday
+ backlog_item_owner = backlog_item.owner
+ user_no_activity_on_backlog_items[backlog_item_owner] ||= []
+ user_no_activity_on_backlog_items[backlog_item_owner] << backlog_item
+ end
+ end
+ end
+
+ # Send the e-mail
+ user_no_activity_on_backlog_items.each do |owner, backlog_items|
+ UserMailer.deliver_no_activity_recorded(owner, backlog_items)
+ end
+
+ end
+
+ scheduler.join
+end
+
+# Run all threads
+threads.each { |thread| thread.run }
\ No newline at end of file
--
1.5.2.4
15 years, 5 months
[PROJXP [PATCH] Emails are sent when no activity is recorded. #10
by Benjamin LAN-SUN-LUK
Signed-off-by: Benjamin <benjamin.lan-sun-luk(a)supinfo.com>
---
app/models/user_mailer.rb | 10 +++++
.../user_mailer/no_activity_recorded.html.erb | 6 +++
config/environment.rb | 5 ++-
config/initializers/schedules.rb | 37 ++++++++++++++++++++
4 files changed, 57 insertions(+), 1 deletions(-)
create mode 100644 app/views/user_mailer/no_activity_recorded.html.erb
create mode 100644 config/initializers/schedules.rb
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index 73308af..8d60671 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -7,4 +7,14 @@ class UserMailer < ActionMailer::Base
subject "Your password"
body :user => user, :new_password => new_password
end
+
+ # Send an e-mail to an user an notify him that no-activity has been detected
+ # for some backlog items.
+ #
+ def no_activity_recorded(user, backlog_items)
+ recipients user.email
+ from "no_reply(a)projxp.org" # TODO Email must be edit
+ subject "No activity has been detected"
+ body :user => user, :backlog_items => backlog_items
+ end
end
diff --git a/app/views/user_mailer/no_activity_recorded.html.erb b/app/views/user_mailer/no_activity_recorded.html.erb
new file mode 100644
index 0000000..e4acd3c
--- /dev/null
+++ b/app/views/user_mailer/no_activity_recorded.html.erb
@@ -0,0 +1,6 @@
+Dear <%= @user.display_name %>,
+
+No activities was detected on this backlogs:
+<% @backlog_items.each do |backlog_item|%>
+<%= backlog_item.user_story.title %>
+<% end %>
diff --git a/config/environment.rb b/config/environment.rb
index af8a593..1687102 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -72,6 +72,9 @@ Rails::Initializer.run do |config|
# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc
+
+ # Gems
+ config.gem 'openwferu-scheduler', :lib => 'openwfe/util/scheduler'
end
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
@@ -82,7 +85,7 @@ ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
# Mail configuration.
# Please complete the config file are locate at /config/mailer.yml
-#
+#
require "smtp_tls"
mailer_config = File.open("#{RAILS_ROOT}/config/mailer.yml")
diff --git a/config/initializers/schedules.rb b/config/initializers/schedules.rb
new file mode 100644
index 0000000..287756c
--- /dev/null
+++ b/config/initializers/schedules.rb
@@ -0,0 +1,37 @@
+require 'fastthread'
+require 'openwfe/util/scheduler'
+include OpenWFE
+
+# Initialize a threads array
+threads = []
+
+threads << Thread.new do
+ scheduler = Scheduler.new
+ scheduler.start
+
+ # Do this everyday at 10:00 am
+ scheduler.schedule('0 8 * * *') do
+
+ user_no_activity_on_backlog_items = {}
+ BacklogItem.find_all_by_state(BacklogItem::STATE_ASSIGNED).each do |backlog_item|
+ backlog_item.tasks.each do |task|
+ if task.created_at.to_date < Date.yesterday
+ backlog_item_owner = backlog_item.owner
+ user_no_activity_on_backlog_items[backlog_item_owner] ||= []
+ user_no_activity_on_backlog_items[backlog_item_owner] << backlog_item
+ end
+ end
+ end
+
+ # Send the e-mail
+ user_no_activity_on_backlog_items.each do |owner, backlog_items|
+ UserMailer.deliver_no_activity_recorded(owner, backlog_items)
+ end
+
+ end
+
+ scheduler.join
+end
+
+# Run all threads
+threads.each { |thread| thread.run }
\ No newline at end of file
--
1.5.2.4
15 years, 5 months
[PROJXP [PATCH] Emails are sent when no activity is recorded. #10
by Benjamin LAN-SUN-LUK
Signed-off-by: Benjamin <benjamin.lan-sun-luk(a)supinfo.com>
---
app/models/user_mailer.rb | 10 +++++
.../user_mailer/no_activity_recorded.html.erb | 6 +++
config/environment.rb | 5 ++-
config/initializers/schedules.rb | 37 ++++++++++++++++++++
4 files changed, 57 insertions(+), 1 deletions(-)
create mode 100644 app/views/user_mailer/no_activity_recorded.html.erb
create mode 100644 config/initializers/schedules.rb
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index 73308af..8d60671 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -7,4 +7,14 @@ class UserMailer < ActionMailer::Base
subject "Your password"
body :user => user, :new_password => new_password
end
+
+ # Send an e-mail to an user an notify him that no-activity has been detected
+ # for some backlog items.
+ #
+ def no_activity_recorded(user, backlog_items)
+ recipients user.email
+ from "no_reply(a)projxp.org" # TODO Email must be edit
+ subject "No activity has been detected"
+ body :user => user, :backlog_items => backlog_items
+ end
end
diff --git a/app/views/user_mailer/no_activity_recorded.html.erb b/app/views/user_mailer/no_activity_recorded.html.erb
new file mode 100644
index 0000000..e4acd3c
--- /dev/null
+++ b/app/views/user_mailer/no_activity_recorded.html.erb
@@ -0,0 +1,6 @@
+Dear <%= @user.display_name %>,
+
+No activities was detected on this backlogs:
+<% @backlog_items.each do |backlog_item|%>
+<%= backlog_item.user_story.title %>
+<% end %>
diff --git a/config/environment.rb b/config/environment.rb
index af8a593..1687102 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -72,6 +72,9 @@ Rails::Initializer.run do |config|
# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc
+
+ # Gems
+ config.gem 'openwferu-scheduler', :lib => 'openwfe/util/scheduler'
end
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
@@ -82,7 +85,7 @@ ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
# Mail configuration.
# Please complete the config file are locate at /config/mailer.yml
-#
+#
require "smtp_tls"
mailer_config = File.open("#{RAILS_ROOT}/config/mailer.yml")
diff --git a/config/initializers/schedules.rb b/config/initializers/schedules.rb
new file mode 100644
index 0000000..287756c
--- /dev/null
+++ b/config/initializers/schedules.rb
@@ -0,0 +1,37 @@
+require 'fastthread'
+require 'openwfe/util/scheduler'
+include OpenWFE
+
+# Initialize a threads array
+threads = []
+
+threads << Thread.new do
+ scheduler = Scheduler.new
+ scheduler.start
+
+ # Do this everyday at 10:00 am
+ scheduler.schedule('0 8 * * *') do
+
+ user_no_activity_on_backlog_items = {}
+ BacklogItem.find_all_by_state(BacklogItem::STATE_ASSIGNED).each do |backlog_item|
+ backlog_item.tasks.each do |task|
+ if task.created_at.to_date < Date.yesterday
+ backlog_item_owner = backlog_item.owner
+ user_no_activity_on_backlog_items[backlog_item_owner] ||= []
+ user_no_activity_on_backlog_items[backlog_item_owner] << backlog_item
+ end
+ end
+ end
+
+ # Send the e-mail
+ user_no_activity_on_backlog_items.each do |owner, backlog_items|
+ UserMailer.deliver_no_activity_recorded(owner, backlog_items)
+ end
+
+ end
+
+ scheduler.join
+end
+
+# Run all threads
+threads.each { |thread| thread.run }
\ No newline at end of file
--
1.5.2.4
15 years, 5 months
Re: [PROJXP Question
by Darryl L. Pierce
(moving this to projxp-devel(a)lists.fedorahosted.org)
On Tue, Oct 21, 2008 at 10:19 AM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
> Okay ;-).
>
> I have another question. I'm not sure if i have understand the description
> of the task #10:
> "If a day has passed since the user updated an open, active backlog item,
> they are sent a nag email reminding them to update the status."
> Can you give me more details about this ?
Sure.
Every day the system should go through the backlog_items table and
look for any backlog_items that are marked as "Accepted" but which
don't have an entry in the tasks table that's less than 24 hours old.
Here's a scenario:
On Monday I accept a backlog items #1 and #2. I do some work on both
and log tasks. Those tasks have Monday's date.
On Tuesday I do only log tasks for backlog item #2. Those tasks have
Tuesday's date.
On Wednesday morning the system should see that backlog item #1 did
not get any tasks logged against it for over 24 hours (the last task
on it is dated Monday) and should send me an email about that.
On Wednesday I don't do anything, or don't log any tasks.
On Thursday morning the system should see that both backlog items #1
and #2 have no tasks logged against them for over 24 hours and sends
me one email listing both of those items.
Does that sound clearer?
--
Darryl L. Pierce <mcpierce(a)gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
15 years, 5 months
Re: Question
by Darryl L. Pierce
On Mon, Oct 20, 2008 at 3:47 PM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
> I'm going to start the task #10. And i need to use a gem
> "openwferu-scheduler", where can i notify this ?
I looked briefly at this gem a while back, but not in a lot of
details. It's workflow engine that we could use for moving tasks
through a from pending to accepted, completed, verified, etc. isn't
it?
--
Darryl L. Pierce <mcpierce(a)gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
15 years, 5 months
Re: Question
by Darryl L. Pierce
On Mon, Oct 20, 2008 at 3:50 PM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
> Where can i "said that i use this plugin" ?
Do you mean where can you put into the code a statement that we depend
on that plugin? If so, you can create a new file in the doc directory
called "Dependencies" that lists them.
Is it available as a gem? If so, then you can add it to the
config/Environment.rb file as a dependency there. That way a user can
do "rake gems:install" to get the gems for their system without us
having to package them.
--
Darryl L. Pierce <mcpierce(a)gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
15 years, 5 months
Re: Question
by Darryl L. Pierce
On Mon, Oct 20, 2008 at 3:47 PM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
> I'm going to start the task #10. And i need to use a gem
> "openwferu-scheduler", where can i notify this ?
Sorry, not sure what you mean by "notify this". Can you restate the question?
--
Darryl L. Pierce <mcpierce(a)gmail.com>
Visit the Infobahn Offramp: <http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
15 years, 5 months