Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

score? #5

Open
ralyodio opened this issue Jun 9, 2014 · 9 comments
Open

score? #5

ralyodio opened this issue Jun 9, 2014 · 9 comments

Comments

@ralyodio
Copy link

ralyodio commented Jun 9, 2014

is there a way to tell the score?

Like if a post has 3 downvotes and 1 upvote the "score" would be -2.

@cristiandouce
Copy link
Owner

@chovy Not right now (yes, but not by a single method). But I think I could add it by the night. It's been requested more than once.

You could get that number now by var score = comment.upvotes() - comment.downvotes().

This would allow you to weight those values any way you like.

@ralyodio
Copy link
Author

ralyodio commented Jun 9, 2014

Yeah, i started thinking last night, its more flexible by providing the arrays you do provides. Allows you to customize the display of a count in whatever way you want.

@johnstonmatt
Copy link

An option to include score would be really helpful, it would permit query.sort ('-score') which I think means sort from top voted. If you don't feel like it is a good fit, do you have any suggestions for implementation? I think I would like it to be updated on each .upvote() or .downvote(). Thanks for your work so far!

@cristiandouce
Copy link
Owner

Hi @johnstonmatt. You could also have a pre save hook and do any transformation for the .score property on your model. You may as well define it the way you prefer as long as it's not attached to the plugin.

I was thinking on maybe supporting a function transformation at the config level for that. But it would end doing the same thing.

Let me know if that works fine.

@johnstonmatt
Copy link

A pre save hook sounds like exactly what I want, I'll try to implement that myself. Thanks for your help, and for sharing your work. If I make any interesting optimizations or discoveries in my implementation I will share them.

@cristiandouce
Copy link
Owner

Sure, thanks! Any PR would be reviewed and very welcome! 😀

@AlmogBaku
Copy link

I think that virtual is could be a better fit for your needs

@bonesoul
Copy link

bonesoul commented May 9, 2016

Please merge #9

@cristiandouce
Copy link
Owner

@raistlinthewiz will take a look tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants