The rating logic structure
The initial rating logic will have three methods:
getTrends():
To fetch the latest trends from a URLrateTrends()
: To rate a particular news entry based on the trendrateDate()
: To rate a particular news entry based on its published date
First we need to fetch a list of keywords, which have been trending for the past hour. Then we need to investigate the news items and find out if any of the current trends are available in them. If the answer is yes we need to add the rank of each trend to the news. In other words, not all items in Google Trends have the same value and they are sorted by their popularity. Finally, we need to give an extra point to the news that was published in the last 24 hours. Based on this logic, create a new class named rating.logic.ts
and add the initial code as follows:
// src/app/rating/rating.logic.ts export class RatingLogic { //ToDo: construct the service object constructor() {} //ToDo: Fetch the latest trends from the given URL...