The rating service structure
To make the development clear and easy, let's create the service class with empty methods and implement them as we proceed.
Head to the /rating
folder inside your source code and create a new class as follows:
// src/app/rating/rating.service.ts import {Injectable} from "@angular/core"; @Injectable() export class RatingService { //ToDo: construct the service object constructor() {} //ToDo: get the collected news from Firebase db getNews() {} //ToDo: get the latest trends to show them inside the template getTrends() {} //ToDo: rate the news based on constructed rules rateNews(){} }
The first thing that we need to take care of is the business logic that we are going to use for rating. As we discussed before, the news date and number of important keywords are what we are going to begin with. This business logic will live in its own class (Separation of Concerns). That means if it was required to change or add more rating items...