Showing top metrics from skill groups

Showing top metrics from skill groups

SUSI.AI shows top metrics on the home page. They include highest rated skills, most used skills, latest skills and skills with most feedbacks etc. Now the idea is to include top skills from a particular category also. For example “SUSI, what are your top games”? So how to fetch the required metrics in a generalized way.

Updating the skill metrics data API

Add an API parameter in SkillMetricsDataService.java to specify the names of groups to fetch the required metrics. It accepts a semicolon (;) separated list of group names. If no group is passed then by default it shows the top games.

String metrics_list = call.get("metrics", "Games, Trivia and Accessories");
String[] metrics_names = metrics_list.split(";");

Split the metrics parameter by semicolon and store in an array. This array contains all the groups of which top skills are to be displayed on the CMS home page. Loop over the array, group by group and filter out the skills that don’t belong to the current metrics group. Sort the filtered skills in decreasing order of the overall rating. But this sorting does not simply arrange the skills in decreasing order of their overall rating. Actually, it divides the skills into 2 halves. The first half contains the skills that have been rated by at least 10 users in decreasing order of the overall ratings. And the second half contains the rest of the skills in decreasing order of their overall rating.

for (String metric_name : metrics_names) {
    try {
        metric_name = metric_name.trim();
        List<JSONObject> groupJsonValues = new ArrayList<JSONObject>();
        for (int i = 0; i < jsonArray.length(); i++) {
            if (jsonArray.getJSONObject(i).get("group").toString().equals(metric_name)) {
                groupJsonValues.add(jsonArray.getJSONObject(i));
            }
        }
        // Get skills based on ratings of a particular group
        SusiSkill.sortByAvgStar(groupJsonValues, false);

        JSONArray topGroup = new JSONArray();
        topGroup = getSlicedArray(groupJsonValues, count);
        skillMetrics.put(metric_name, topGroup);
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}

So if top games and news skills are to be shown on the CMS then the API endpoint looks like :

https://api.susi.ai/cms/getSkillMetricsData.json?metrics=Games, Trivia and Accessories; News

And the response is like :

{
	accepted: true,
	model: "general",
	group: "All",
	language: "en",
	metrics: {
		+newest: [...],
		+latest: [...],
		+rating: [...],
		+usage: [...],
		+feedback: [...],
		+staffPicks: [...],
		+Games, Trivia and Accessories: [...],
		+News: [...]
	},
	message: "Success: Fetched skill data based on metrics"
}

Resources

  • NA