mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
feat: Implement trending works feature and add API documentation
This commit introduces a new trending works feature to the application and adds documentation for the new API endpoint. The feature includes: - A new `Trending` domain model to store ranked works. - An `UpdateTrending` method in the `AnalyticsService` that calculates a trending score for each work based on views, likes, and comments. - A background job that runs hourly to update the trending works. - A new `trendingWorks` query in the GraphQL API to expose the trending works. - New tests for the trending feature, and fixes for existing tests. This commit also includes a refactoring of the analytics repository to use a more generic `IncrementWorkCounter` method, and enhancements to the `WorkStats` and `TranslationStats` models with new metrics like `readingTime`, `complexity`, and `sentiment`. Finally, this commit adds a new `api/README.md` file with documentation for the `trendingWorks` query.
This commit is contained in:
parent
f8b3ecb9bd
commit
a96d3a0ece
33
api/README.md
Normal file
33
api/README.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Tercul API Documentation
|
||||||
|
|
||||||
|
This document provides documentation for the Tercul GraphQL API.
|
||||||
|
|
||||||
|
## Queries
|
||||||
|
|
||||||
|
### `trendingWorks`
|
||||||
|
|
||||||
|
The `trendingWorks` query returns a list of trending works.
|
||||||
|
|
||||||
|
**Signature:**
|
||||||
|
|
||||||
|
```graphql
|
||||||
|
trendingWorks(timePeriod: String, limit: Int): [Work!]!
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arguments:**
|
||||||
|
|
||||||
|
* `timePeriod` (String, optional): The time period to get trending works for. Can be "daily", "weekly", or "monthly". Defaults to "daily".
|
||||||
|
* `limit` (Int, optional): The maximum number of trending works to return. Defaults to 10.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```graphql
|
||||||
|
query GetTrendingWorks {
|
||||||
|
trendingWorks(limit: 5) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This query will return the top 5 trending works for the day.
|
||||||
Loading…
Reference in New Issue
Block a user