• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Total vote count on topic list

Scheduled Pinned Locked Moved Developer FAQ
8 Posts 3 Posters 357 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • crazycellsC Offline
    crazycellsC Offline
    crazycells
    wrote on last edited by
    #1

    @baris can we have another option to calculate the vote numbers of a topic in ACP? So each admin can decide for their forum. I prefer a calculation where all of the positive and negative votes in the thread are considered. Sometimes the first post may not be the key post, but rather it is a question. So it looks 0 vote, although the topic itself is very useful.

    Screen Shot 2023-05-07 at 16.34.46.png

    phenomlabP 1 Reply Last reply
    1
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to crazycells on last edited by
    #2

    @crazycells I agree with this. I too have a number of posts on my forum where the initial didn't have many upvotes but subsequent ones do.

    1 Reply Last reply
    1
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #3

    Isn't this how stack overflow works as well? The vote count is for the question itself. I took a look at that code and it wasn't trivial to implement this without a new function so I added that here: https://github.com/NodeBB/NodeBB/pull/11579.

    If anyone wants to build it as a plugin it can be done using the function from the above pull request. I will leave the code required here.

    In plugin.json add this hook, it gets fired whenever a list of topics is loaded.

    { "hook": "filter:topics.get", "method": "filterTopicsGet" }
    

    Now the code that will recalculate the vote count from the posts of the topics:

    const db = require.main.require('./src/database');
    
    library.filterTopicsGet = async (hookData) => {
    	const voteData = await db.getSortedSetsMembersWithScores(
    		hookData.topics.map(t => `tid:${t.tid}:posts:votes`)
    	);
    	hookData.topics.forEach((t, index) => {
    		if (t) {
    			const allvotes = voteData[index].reduce((acc, cur) => acc + cur.score, 0);
    			t.votes += allvotes;
    		}
    	});
    	return hookData;
    };
    

    Now the vote displayed on the topic list will be the total number of votes from all the posts in the topic.

    crazycellsC 1 Reply Last reply
    6
  • julianJ julian moved this topic from Feature Requests on
  • crazycellsC Offline
    crazycellsC Offline
    crazycells
    replied to <baris> on last edited by
    #4

    @baris thanks 🙂 I hope someone with the necessary skills will step in and write the plugin for us 😄

    Please Cat GIF

    1 Reply Last reply
    1
  • crazycellsC Offline
    crazycellsC Offline
    crazycells
    wrote on last edited by
    #5

    thanks @oplik0 and @baris for the plugin...

    GitHub - oplik0/nodebb-plugin-total-vote-count: Calculate vote totals based on all posts in topics and not just the inital post

    Calculate vote totals based on all posts in topics and not just the inital post - GitHub - oplik0/nodebb-plugin-total-vote-count: Calculate vote totals based on all posts in topics and not just the inital post

    favicon

    GitHub (github.com)

    phenomlabP 1 Reply Last reply
    4
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to crazycells on last edited by phenomlab
    #6

    @crazycells now this is definitely a plugin I'm going to use. Nobody up votes the original topic, but always the individual posts.

    crazycellsC 1 Reply Last reply
    1
  • crazycellsC Offline
    crazycellsC Offline
    crazycells
    replied to phenomlab on last edited by
    #7

    @phenomlab yeap, we have both cases in the forum, but this calculation makes more sense to us than the first post only.

    phenomlabP 1 Reply Last reply
    1
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to crazycells on last edited by
    #8

    @crazycells said in Total vote count on topic list:

    but this calculation makes more sense to us than the first post only.

    And for me.

    1 Reply Last reply
    1

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development