mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
small scoring tweaks
This commit is contained in:
parent
cb3918f933
commit
e3cd1fb017
4 changed files with 11 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
const Post = ({document}) => {
|
const Post = ({document, currentUser}) => {
|
||||||
|
|
||||||
({ListContainer, CommentList, CommentNew, PostCategories, SocialShare} = Telescope.components);
|
({ListContainer, CommentList, CommentNew, PostCategories, SocialShare, Vote, PostStats} = Telescope.components);
|
||||||
|
|
||||||
const post = document;
|
const post = document;
|
||||||
const htmlBody = {__html: post.htmlBody};
|
const htmlBody = {__html: post.htmlBody};
|
||||||
|
@ -8,10 +8,15 @@ const Post = ({document}) => {
|
||||||
return (
|
return (
|
||||||
<div className="post">
|
<div className="post">
|
||||||
|
|
||||||
|
<Vote post={post} currentUser={currentUser}/>
|
||||||
|
|
||||||
<h3>{post.title}</h3>
|
<h3>{post.title}</h3>
|
||||||
<SocialShare url={ Posts.getLink(post) } title={ post.title }/>
|
<SocialShare url={ Posts.getLink(post) } title={ post.title }/>
|
||||||
<p>{post.commentCount} comments</p>
|
<p>{post.commentCount} comments</p>
|
||||||
<p>{moment(post.postedAt).fromNow()}</p>
|
<p>{moment(post.postedAt).fromNow()}</p>
|
||||||
|
|
||||||
|
<PostStats post={post} />
|
||||||
|
|
||||||
{post.categoriesArray ? <PostCategories categories={post.categoriesArray} /> : ""}
|
{post.categoriesArray ? <PostCategories categories={post.categoriesArray} /> : ""}
|
||||||
<div dangerouslySetInnerHTML={htmlBody}></div>
|
<div dangerouslySetInnerHTML={htmlBody}></div>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ const PostStats = ({post}) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="post-stats">
|
<div className="post-stats">
|
||||||
<span title="Score"><Icon name="score"/> {Math.floor(post.score*100)/100} <span className="sr-only">Score</span></span>
|
{post.score ? <span title="Score"><Icon name="score"/> {Math.floor(post.score*10000)/10000} <span className="sr-only">Score</span></span> : ""}
|
||||||
<span title="Upvotes"><Icon name="upvote"/> {post.upvotes} <span className="sr-only">Upvotes</span></span>
|
<span title="Upvotes"><Icon name="upvote"/> {post.upvotes} <span className="sr-only">Upvotes</span></span>
|
||||||
<span title="Clicks"><Icon name="clicks"/> {post.clickCount} <span className="sr-only">Clicks</span></span>
|
<span title="Clicks"><Icon name="clicks"/> {post.clickCount} <span className="sr-only">Clicks</span></span>
|
||||||
<span title="Views"><Icon name="views"/> {post.viewCount} <span className="sr-only">Views</span></span>
|
<span title="Views"><Icon name="views"/> {post.viewCount} <span className="sr-only">Views</span></span>
|
||||||
|
|
|
@ -37,10 +37,8 @@ Telescope.updateScore = function (args) {
|
||||||
// time decay factor
|
// time decay factor
|
||||||
var f = 1.3;
|
var f = 1.3;
|
||||||
|
|
||||||
// use baseScore if defined, if not just use the number of votes
|
// use baseScore if defined, if not just use 0
|
||||||
// note: for transition period, also use votes if there are more votes than baseScore
|
var baseScore = item.baseScore || 0;
|
||||||
// var baseScore = Math.max(item.votes || 0, item.baseScore || 0);
|
|
||||||
var baseScore = item.baseScore;
|
|
||||||
|
|
||||||
// HN algorithm
|
// HN algorithm
|
||||||
var newScore = baseScore / Math.pow(ageInHours + 2, f);
|
var newScore = baseScore / Math.pow(ageInHours + 2, f);
|
||||||
|
|
|
@ -4,6 +4,7 @@ Meteor.startup(function () {
|
||||||
|
|
||||||
// active items get updated every N seconds
|
// active items get updated every N seconds
|
||||||
Meteor.setInterval(function () {
|
Meteor.setInterval(function () {
|
||||||
|
|
||||||
var updatedPosts = 0;
|
var updatedPosts = 0;
|
||||||
var updatedComments = 0;
|
var updatedComments = 0;
|
||||||
// console.log('tick ('+scoreInterval+')');
|
// console.log('tick ('+scoreInterval+')');
|
||||||
|
|
Loading…
Add table
Reference in a new issue