mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-30 19:48:18 +08:00
Add check for tasks complete in project notifications (#1657)
This commit is contained in:
parent
ffb0db06b9
commit
8ba0555922
4 changed files with 5 additions and 3 deletions
|
@ -78,6 +78,7 @@ class MyModule < ApplicationRecord
|
||||||
Time.current.utc + 1.day)
|
Time.current.utc + 1.day)
|
||||||
end)
|
end)
|
||||||
scope :workflow_ordered, -> { order(workflow_order: :asc) }
|
scope :workflow_ordered, -> { order(workflow_order: :asc) }
|
||||||
|
scope :uncomplete, -> { where(state: 'uncompleted') }
|
||||||
|
|
||||||
# A module takes this much space in canvas (x, y) in database
|
# A module takes this much space in canvas (x, y) in database
|
||||||
WIDTH = 30
|
WIDTH = 30
|
||||||
|
|
|
@ -242,7 +242,7 @@ class Project < ApplicationRecord
|
||||||
def notifications_count(user)
|
def notifications_count(user)
|
||||||
res = 0
|
res = 0
|
||||||
assigned_modules(user).find_each do |t|
|
assigned_modules(user).find_each do |t|
|
||||||
res += 1 if t.is_overdue? || t.is_one_day_prior?
|
res += 1 if (t.is_overdue? || t.is_one_day_prior?) && !t.completed?
|
||||||
end
|
end
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,6 +65,7 @@ class ProjectsOverviewService
|
||||||
def fetch_records
|
def fetch_records
|
||||||
due_modules =
|
due_modules =
|
||||||
MyModule.active
|
MyModule.active
|
||||||
|
.uncomplete
|
||||||
.overdue
|
.overdue
|
||||||
.or(MyModule.one_day_prior)
|
.or(MyModule.one_day_prior)
|
||||||
.distinct
|
.distinct
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<ul class="no-style double-line content-notifications">
|
<ul class="no-style double-line content-notifications">
|
||||||
<% nr_of_notifications = 0 %>
|
<% nr_of_notifications = 0 %>
|
||||||
<% @modules.each do |mod| %>
|
<% @modules.each do |mod| %>
|
||||||
<% if mod.is_overdue? %>
|
<% if mod.is_overdue? && !mod.completed? %>
|
||||||
<% nr_of_notifications += 1 %>
|
<% nr_of_notifications += 1 %>
|
||||||
<% days = t("projects.index.module_overdue_days", count: mod.overdue_for_days) %>
|
<% days = t("projects.index.module_overdue_days", count: mod.overdue_for_days) %>
|
||||||
<li class="notification alert-red">
|
<li class="notification alert-red">
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
</div>
|
</div>
|
||||||
<%=t "projects.index.module_overdue_html", module: mod.name, days: days %>
|
<%=t "projects.index.module_overdue_html", module: mod.name, days: days %>
|
||||||
</li>
|
</li>
|
||||||
<% elsif mod.is_one_day_prior? %>
|
<% elsif mod.is_one_day_prior? && !mod.completed? %>
|
||||||
<% nr_of_notifications += 1 %>
|
<% nr_of_notifications += 1 %>
|
||||||
<li class="notification alert-yellow">
|
<li class="notification alert-yellow">
|
||||||
<div class="date-time">
|
<div class="date-time">
|
||||||
|
|
Loading…
Reference in a new issue