Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 应用程序中热门话题的趋势分析_Node.js_Mongodb - Fatal编程技术网

Node.js 应用程序中热门话题的趋势分析

Node.js 应用程序中热门话题的趋势分析,node.js,mongodb,Node.js,Mongodb,我创建了一个简单的移动应用程序,后端由Node.JS和MongoDB(Mongoose)和express组成。 我的应用程序有主题,包括以下字段: _id、标题、副标题、详细信息、…、标记[]、viewCount、likeCount、shareCount、commentsCount、updatedAt、createdAt 现在,我想找到主要基于viewCount的趋势主题(当前热门和流行的主题),如eCount、shareCount、commentsCount(欢迎其他建议) 目前我使用的公式如

我创建了一个简单的移动应用程序,后端由Node.JS和MongoDB(Mongoose)和express组成。 我的应用程序有主题,包括以下字段:

_id、标题、副标题、详细信息、…、标记[]、viewCount、likeCount、shareCount、commentsCount、updatedAt、createdAt

现在,我想找到主要基于viewCount的趋势主题(当前热门和流行的主题),如eCount、shareCount、commentsCount(欢迎其他建议)

目前我使用的公式如下:

popularity = viewCount * 1 + likeCount * 2 + shareCount * 2 + commentsCount * 3
但这是愚蠢的,因为它没有考虑到趋势分析的主要目标,即当前(现在)

关于如何改进我的公式以获得预期结果的任何建议


注意:我愿意在我的数据库中添加或修改字段

这是我最后想到的

popularity = 
(viewCount * 1 + likeCount * 2 + shareCount * 2 + commentsCount * 3) / actionTimestamp
其中actionTimestamp在每次更新viewCount时都会更新,例如,帐户、shareCount、commentsCount

我知道这是不可靠的,任何帮助都是值得的