liplum/flarum-trends
Composer 安装命令:
composer require liplum/flarum-trends
包简介
The trending discussions for Flarum
README 文档
README
A Flarum extension to serve API for trending discussions.
Get Started
Installation
To install the dependencies for this extension, run the following commands:
composer require michaelbelgium/flarum-discussion-views composer require liplum/flarum-trends
Update
composer update liplum/flarum-trends
Usage
This extension provides an API endpoint to retrieve trending discussions based on recent activity.
Endpoint
GET /api/trends
Query Parameters
limit(integer, optional): The maximum number of discussions to return. Defaults to10.
Response
The API returns a JSON array of discussion objects. Each discussion object contains the following properties:
id(string): The discussion ID.title(string): The discussion title.commentCount(integer): The number of comments in the discussion.participantCount(integer): The number of participants in the discussion.viewCount(integer): The number of views of the discussion.createdAt(string): The creation time of the discussion in ISO 8601 format.lastActivityAt(string): The last activity time of the discussion in ISO 8601 format.shareUrl(string): The URL to share the discussion.trendingScore(number): The trending score of the discussion.user(object): An object containing the user's ID and username.id(string): The user ID.username(string): The username.
Typing
interface TrendingDiscussionsResponse { data: TrendingDiscussion[]; } interface TrendingDiscussion { type: 'discussions'; id: string; attributes: { title: string; commentCount: number; participantCount: number; viewCount: number; createdAt: string; lastActivityAt: string; shareUrl: string; trendingScore: number; }; relationships: { user: { data: { type: 'users'; id: string; attributes: { username: string; }; }; }; }; }
Example Request
GET /api/trends/recent?limit=5
Example Response
{
"data": [
{
"type": "discussions",
"id": "123",
"attributes": {
"title": "Discussion Title 1",
"commentCount": 50,
"participantCount": 20,
"viewCount": 1000,
"createdAt": "2023-10-27T10:00:00+00:00",
"lastActivityAt": "2023-10-27T11:30:00+00:00",
"shareUrl": "https://discuss.flarum.org/d/123",
"trendingScore": 1234.56
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "1",
"attributes": {
"username": "user1"
}
}
}
}
},
{
"type": "discussions",
"id": "456",
"attributes": {
"title": "Discussion Title 2",
"commentCount": 30,
"participantCount": 15,
"viewCount": 750,
"createdAt": "2023-10-26T15:30:00+00:00",
"lastActivityAt": "2023-10-26T15:30:00+00:00",
"shareUrl": "https://discuss.flarum.org/d/456",
"trendingScore": 876.54
},
"relationships": {
"user": {
"data": {
"type": "users",
"id": "2",
"attributes": {
"username": "user2"
}
}
}
}
}
]
}
Trending Score Formula
$S$ = [($W_c \times N_c$) + ($W_p \times N_p$) + ($W_v \times N_v$)] $\times D(days)$
Where:
- $W_c$: Weight assigned to comment count.
- $N_c$: Number of comments in the discussion.
- $W_p$: Weight assigned to participant count.
- $N_p$: Number of participants in the discussion.
- $W_v$: Weight assigned to view count.
- $N_v$: Number of views of the discussion.
- $D(days)$: Decay factor that controls the rate of time decay. It gradually reduces the score over time, reaching zero at the specified time limit.
The trending score is calculated for each discussion, and discussions are then sorted in descending order based on their scores.
Notes
- Hidden, locked, and private discussions are excluded from the results.
liplum/flarum-trends 适用场景与选型建议
liplum/flarum-trends 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.26k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「hot」 「trends」 「flarum」 「popular」 「trending」 「flarum-extension」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 liplum/flarum-trends 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 liplum/flarum-trends 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 liplum/flarum-trends 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The lib allows to watch phpunit tests
Hot Discussions widget for Flarum
Adds more BBCode
Output of discussions lists in form of cards
Show 3 cards with hot discussions preview
Provides a Metrics for Laravel 5
统计信息
- 总下载量: 1.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-13