mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-30 11:41:19 +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)
|
||||
end)
|
||||
scope :workflow_ordered, -> { order(workflow_order: :asc) }
|
||||
scope :uncomplete, -> { where(state: 'uncompleted') }
|
||||
|
||||
# A module takes this much space in canvas (x, y) in database
|
||||
WIDTH = 30
|
||||
|
|
|
@ -242,7 +242,7 @@ class Project < ApplicationRecord
|
|||
def notifications_count(user)
|
||||
res = 0
|
||||
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
|
||||
res
|
||||
end
|
||||
|
|
|
@ -65,6 +65,7 @@ class ProjectsOverviewService
|
|||
def fetch_records
|
||||
due_modules =
|
||||
MyModule.active
|
||||
.uncomplete
|
||||
.overdue
|
||||
.or(MyModule.one_day_prior)
|
||||
.distinct
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<ul class="no-style double-line content-notifications">
|
||||
<% nr_of_notifications = 0 %>
|
||||
<% @modules.each do |mod| %>
|
||||
<% if mod.is_overdue? %>
|
||||
<% if mod.is_overdue? && !mod.completed? %>
|
||||
<% nr_of_notifications += 1 %>
|
||||
<% days = t("projects.index.module_overdue_days", count: mod.overdue_for_days) %>
|
||||
<li class="notification alert-red">
|
||||
|
@ -13,7 +13,7 @@
|
|||
</div>
|
||||
<%=t "projects.index.module_overdue_html", module: mod.name, days: days %>
|
||||
</li>
|
||||
<% elsif mod.is_one_day_prior? %>
|
||||
<% elsif mod.is_one_day_prior? && !mod.completed? %>
|
||||
<% nr_of_notifications += 1 %>
|
||||
<li class="notification alert-yellow">
|
||||
<div class="date-time">
|
||||
|
|
Loading…
Reference in a new issue