seitime-frappe/frappe/desk/page/activity/activity.py
Shreya Shah acdbb97ba5 Moved feed from Communication to Activity Log (#4435)
* Removed comment_type 'updated'

* New doctype activity log

* Moved feed.py to activity_log

* Updated feed gets stored in activity_log

* Activity page fetches feed from activity_log

* feed match condition change

* modified

* modified hooks.py

* modified sessions.py

* patch added

* naming in patch

* moved login, logout feed to activity_log

* changes in auth.py, hooks.py

* deleted doctype authentication_log and added test cases

* added utils.py in core

* moved some methods from communication.py to utils.py
2017-11-21 15:46:51 +05:30

56 lines
No EOL
1.9 KiB
Python

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: See license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils import cint
from frappe.core.doctype.activity_log.feed import get_feed_match_conditions
@frappe.whitelist()
def get_feed(start, page_length, show_likes=False):
"""get feed"""
match_conditions = get_feed_match_conditions(frappe.session.user)
result = frappe.db.sql("""select X.*
from (select name, owner, modified, creation, seen, comment_type,
reference_doctype, reference_name, link_doctype, link_name, subject,
communication_type, communication_medium, content
from `tabCommunication`
where
communication_type in ("Communication", "Comment")
and communication_medium != "Email"
and (comment_type is null or comment_type != "Like"
or (comment_type="Like" and (owner=%(user)s or reference_owner=%(user)s)))
{match_conditions}
{show_likes}
union
select name, owner, modified, creation, '0', 'Updated',
reference_doctype, reference_name, link_doctype, link_name, subject,
'Comment', '', content
from `tabActivity Log`) X
order by X.creation DESC
limit %(start)s, %(page_length)s"""
.format(match_conditions="and {0}".format(match_conditions) if match_conditions else "",
show_likes="and comment_type='Like'" if show_likes else ""),
{
"user": frappe.session.user,
"start": cint(start),
"page_length": cint(page_length)
}, as_dict=True)
if show_likes:
# mark likes as seen!
frappe.db.sql("""update `tabCommunication` set seen=1
where comment_type='Like' and reference_owner=%s""", frappe.session.user)
frappe.local.flags.commit = True
return result
@frappe.whitelist()
def get_heatmap_data():
return dict(frappe.db.sql("""select unix_timestamp(date(creation)), count(name)
from `tabActivity Log`
where
date(creation) > subdate(curdate(), interval 1 year)
group by date(creation)
order by creation asc"""))