- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:15 PM
It seems to me every time I check, that the Knowledge Most Viewed Articles Widget is an ALL TIME view count. This is not optimal, and I wonder if it can be changed. If yes, How?
Example Scenario:
- In January 2012, there was a Virus issue, so there was a How to remedy Virus article created and viewed 2000 times (in January)
- Then by mid-January, the issue was resolved by Tier 3, so there is no longer a virus, BUT...
- The top Viewed article of all time... in 2013, 2014, and 2016 is still the How to remedy Virus article?... that is dumb.
- Clearly now, the How to make too much money article is far more important, but the Virus article has more Views.
There should be a setting on this widget to allow for a time range, like most other widgets - default of 30 days, but changeable (by the viewer of the widget?) to today, past 7 days, past 30 days, past year, all time).
Is there a setting like that for the widget? Can there be? Am I crazy for even considering this as a standard KB offering?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 07:33 PM
Your admins need to update the widget server to something like this
(function() {
data.articles = [];
options.title = options.title || gs.getMessage("Most Viewed Articles");
var z = new GlideAggregate('kb_use');
z.addAggregate('COUNT', 'article');
if (options.kb_category)
z.addQuery("article.kb_category", options.kb_category);
z.addQuery('sys_created_on', '>=', gs.daysAgo(30)); // Most views in the past 30 Days
z.orderByDesc('article');
z.setLimit(options.max_number || 5);
z.query();
while (z.next()) {
if (!z.canRead())
continue;
var count = z.getAggregate('count', 'article');
var a = {};
a.short_description = z.article.short_description.toString();
a.sys_view_count = count;
a.sys_id = z.article.toString();
a.published = z.article.published.toString();
data.articles.push(a);
}
})()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 03:53 PM
Do you have any more specific details for adding a time range? Is this something my in-house SN Admins are supposed to already know how to do?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 07:33 PM
Your admins need to update the widget server to something like this
(function() {
data.articles = [];
options.title = options.title || gs.getMessage("Most Viewed Articles");
var z = new GlideAggregate('kb_use');
z.addAggregate('COUNT', 'article');
if (options.kb_category)
z.addQuery("article.kb_category", options.kb_category);
z.addQuery('sys_created_on', '>=', gs.daysAgo(30)); // Most views in the past 30 Days
z.orderByDesc('article');
z.setLimit(options.max_number || 5);
z.query();
while (z.next()) {
if (!z.canRead())
continue;
var count = z.getAggregate('count', 'article');
var a = {};
a.short_description = z.article.short_description.toString();
a.sys_view_count = count;
a.sys_id = z.article.toString();
a.published = z.article.published.toString();
data.articles.push(a);
}
})()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2019 09:14 AM
@dvp,
Thank you for your response. I asked the in-house team again and they re-digested what is already supposed to be true, that this widget is NOT an ALL TIME count, but is configured to the default 30 day setting like other widgets.
Though my reviews seem to occasionally contradict this, I'm going to have to trust my Admins.
I will keep your information in case we find the Admins or the configuration to be invalid.