Improve sticky system by sorting posts by sticky instead of changing score

This commit is contained in:
Sacha Greif 2012-12-20 17:30:54 +01:00
parent a7afcc8046
commit fcc7313449
6 changed files with 6 additions and 91 deletions

View file

@ -65,9 +65,9 @@ var postListSubscription = function(find, options, per_page) {
return handle;
}
var topPostsHandle = postListSubscription(FIND_APPROVED, {sort: {score: -1}}, 10);
var newPostsHandle = postListSubscription(FIND_APPROVED, {sort: {submitted: -1}}, 10);
var bestPostsHandle = postListSubscription(FIND_APPROVED, {sort: {baseScore: -1}}, 10);
var topPostsHandle = postListSubscription(FIND_APPROVED, {sort: {sticky: -1, score: -1}}, 10);
var newPostsHandle = postListSubscription(FIND_APPROVED, {sort: {sticky: -1, submitted: -1}}, 10);
var bestPostsHandle = postListSubscription(FIND_APPROVED, {sort: {sticky: -1, baseScore: -1}}, 10);
var pendingPostsHandle = postListSubscription(
{$or: [{status: STATUS_PENDING}, {status: STATUS_REJECTED}]},
{sort: {score: -1}},

View file

@ -166,54 +166,6 @@ body {
#loading {
height: 300px; }
/* line 53, ../sass/partials/_main.scss */
#tlkio {
position: fixed;
top: 0px;
right: -280px;
-webkit-transition: ease-out right 300ms;
-webkit-transition-delay: 0ms;
-moz-transition: ease-out right 300ms 0ms;
-o-transition: ease-out right 300ms 0ms;
transition: ease-out right 300ms 0ms;
z-index: 1000;
background: #333; }
/* line 60, ../sass/partials/_main.scss */
#tlkio.open {
right: 0px;
-webkit-box-shadow: -1px 0px 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: -1px 0px 5px rgba(0, 0, 0, 0.15);
box-shadow: -1px 0px 5px rgba(0, 0, 0, 0.15); }
/* line 64, ../sass/partials/_main.scss */
#tlkio .open-chat, #tlkio .report-bug {
display: block;
background: #7ac0e4;
-webkit-border-radius: 3px 3px 0px 0px;
-moz-border-radius: 3px 3px 0px 0px;
-ms-border-radius: 3px 3px 0px 0px;
-o-border-radius: 3px 3px 0px 0px;
border-radius: 3px 3px 0px 0px;
position: absolute;
top: 300px;
right: 264px;
text-transform: uppercase;
color: white;
padding: 3px 10px;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
-webkit-box-shadow: -1px 0px 1px rgba(0, 0, 0, 0.15);
-moz-box-shadow: -1px 0px 1px rgba(0, 0, 0, 0.15);
box-shadow: -1px 0px 1px rgba(0, 0, 0, 0.15);
z-index: 1001;
white-space: nowrap; }
/* line 79, ../sass/partials/_main.scss */
#tlkio .report-bug {
top: 400px;
right: 236px; }
/* line 1, ../sass/partials/_typography.scss */
body, textarea, input, button, input[type="submit"], input[type="button"] {
font-family: "Open Sans", "Proxima Nova Soft", "proxima-nova-soft", "PT SANS", "Helvetica Neue", Helvetica, sans-serif;

View file

@ -49,35 +49,4 @@ body{
}
#loading{
height:300px;
}
#tlkio{
position:fixed;
top:0px;
right:-280px;
@include single-transition(ease-out, right, 300ms, 0ms);
z-index:1000;
background:#333;
&.open{
right:0px;
@include box-shadow(-1px 0px 5px black(0.15));
}
.open-chat, .report-bug{
display:block;
background:$blue;
@include border-radius(3px 3px 0px 0px);
position:absolute;
top:300px;
right:264px;
text-transform:uppercase;
color:white;
padding:3px 10px;
@include rotate(270deg);
@include box-shadow(-1px 0px 1px black(0.15));
z-index:1001;
white-space:nowrap;
}
.report-bug{
top:400px;
right:236px;
}
}

View file

@ -71,7 +71,7 @@ Template.post_edit.events = {
});
var properties = {
headline: $('#title').val(),
headline: $('#title').val(),
url: $('#url').val(),
body: instance.editor.exportFile(),
categories: categories,
@ -87,10 +87,6 @@ Template.post_edit.events = {
properties = _.extend(properties, adminProperties);
}
console.log(properties);
Posts.update(selectedPostId,
{
$set: properties

View file

@ -1,6 +1,6 @@
<template name="post_item">
<div class="post post-{{rank}} {{#if sticky}}sticky{{/if}}" id="{{_id}}">
<ul class="post-actions just-a-test">
<ul class="post-actions">
<li class="post-share desktop"><a href="#" class="share-link"><i class="icon-share"></i><span class="action">Share</span></a>
<div class="share-options hidden">
{{#constant}}
@ -44,7 +44,7 @@
| <a href="/posts/{{_id}}/edit" class="edit-link goto-edit">Edit</a>
{{/if}}
{{#if currentUser.isAdmin}}
| <span class="status" style="color:red;">{{status}}</span> votes: {{votes}}, baseScore: {{baseScore}}, score: {{short_score}}, time: {{timestamp}}
| status: {{status}}</span>, votes: {{votes}}, baseScore: {{baseScore}}, score: {{short_score}}
{{/if}}
</p>
</div>

View file

@ -14,8 +14,6 @@ var updateScore = function (collection, id) {
// HN algorithm (same as Bindle)
var newScore = baseScore / Math.pow(ageInHours + 2, 1.3);
if(object.sticky)
newScore=999;
collection.update(id, {$set: {score: newScore}});
// console.log('old score: '+object.baseScore+' | new score: '+newScore+' | score diff: '+Math.abs(newScore-object.baseScore));