updates to kb: unanswered questions show in desktop, questions query moved to server-side
diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js
index 9ea3c89..6010464 100644
--- a/erpnext/startup/startup.js
+++ b/erpnext/startup/startup.js
@@ -136,6 +136,7 @@
show_in_circle('things_todo', r.message.things_todo);
show_in_circle('todays_events', r.message.todays_events);
show_in_circle('open_tasks', r.message.open_tasks);
+ show_in_circle('unanswered_questions', r.message.unanswered_questions);
} else {
clearInterval(wn.updates.id);
diff --git a/erpnext/startup/startup.py b/erpnext/startup/startup.py
index f21f251..0ae3114 100644
--- a/erpnext/startup/startup.py
+++ b/erpnext/startup/startup.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
import webnotes
def get_unread_messages():
@@ -11,9 +12,7 @@
""", webnotes.user.name, as_list=1)
def get_open_support_tickets():
- """
- Returns a count of open support tickets
- """
+ """Returns a count of open support tickets"""
from webnotes.utils import cint
open_support_tickets = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabSupport Ticket`
@@ -21,18 +20,14 @@
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
def get_open_tasks():
- """
- Returns a count of open tasks
- """
+ """Returns a count of open tasks"""
from webnotes.utils import cint
return webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabTask`
WHERE status = 'Open'""")[0][0]
def get_things_todo():
- """
- Returns a count of incomplete todos
- """
+ """Returns a count of incomplete todos"""
from webnotes.utils import cint
incomplete_todos = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabToDo`
@@ -41,9 +36,7 @@
return incomplete_todos and cint(incomplete_todos[0][0]) or 0
def get_todays_events():
- """
- Returns a count of todays events in calendar
- """
+ """Returns a count of todays events in calendar"""
from webnotes.utils import nowdate, cint
todays_events = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabEvent`
@@ -53,6 +46,11 @@
webnotes.session.get('user'), nowdate()))
return todays_events and cint(todays_events[0][0]) or 0
+def get_unanswered_questions():
+ return len(filter(lambda d: d[0]==0,
+ webnotes.conn.sql("""select (select count(*) from tabAnswer
+ where tabAnswer.question = tabQuestion.name) as answers from tabQuestion""")))
+
@webnotes.whitelist()
def get_global_status_messages(arg=None):
return {
@@ -60,5 +58,6 @@
'open_support_tickets': get_open_support_tickets(),
'things_todo': get_things_todo(),
'todays_events': get_todays_events(),
- 'open_tasks': get_open_tasks()
+ 'open_tasks': get_open_tasks(),
+ 'unanswered_questions': get_unanswered_questions()
}