chore(help_article): drop usage of ifnull

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2023-10-31 15:36:01 +05:30
parent 00e222f303
commit 796b11d665
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -44,11 +44,7 @@ class HelpArticle(WebsiteGenerator):
clear_cache()
def update_category(self):
cnt = frappe.db.sql(
"""select count(*) from `tabHelp Article`
where category=%s and ifnull(published,0)=1""",
self.category,
)[0][0]
cnt = frappe.db.count("Help Article", filters={"category": self.category, "published": 1})
cat = frappe.get_doc("Help Category", self.category)
cat.help_articles = cnt
cat.save()
@ -107,7 +103,7 @@ def get_sidebar_items():
from
`tabHelp Category`
where
ifnull(published,0)=1 and help_articles > 0
published = 1 and help_articles > 0
order by
help_articles desc""",
as_dict=True,