Support » Plugins » [Plugin: WP-Polls] Some suggestions and ideas for version 3

  • Hello Lester:

    If you remember me, I was one of those who suggested that you pack polls-js.js a few years ago and make it static. I’m back to bounce off some ideas for version 3, if I may:

    1. Combine the queries. Every poll, on every single page load, executes four database calls.

    SELECT pollq_active FROM wp_pollsq WHERE pollq_id = 1;
    SELECT pollip_aid FROM wp_pollsip WHERE pollip_qid = 1 AND pollip_ip = '';
    SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_timestamp, pollq_expiry, pollq_multiple, pollq_totalvoters FROM wp_pollsq WHERE pollq_id = 1 LIMIT 1;
    SELECT polla_aid, polla_answers, polla_votes FROM wp_pollsa WHERE polla_qid = 1 ORDER BY polla_aid asc;

    Isn’t four a lot? Could enough hits to a Polls Archive page bring down a server?

    2. Create indexes on wp_pollsip. The column pollip_ip badly needs it, e.g., the second query above when there are thousands of recorded votes, as it hopefully becomes. Displaying, showing votes and voting will all be slow.

    3. On the Logs screen, both unfiltered and filtered, please sort the votes descending by date, not by pollip_id. It’s more interesting and it shows how much is the recent interest in the poll’s subject. Sorry, the current sort becomes useless after 100 votes.

    4. Sometimes (due to dropped mysql server connections, I think), the vote and voter counts in wp_pollsq and wp_pollsa don’t match the votes logged in wp_pollsip. Please have a “Recount” button on one of the admin screens that runs the following script.

    ## Optimize, for good measure
    OPTIMIZE TABLE wp_pollsip, wp_pollsq, wp_pollsa;
    ## Update vote count on questions
    UPDATE wp_pollsq SET pollq_totalvotes = (SELECT COUNT(*) FROM wp_pollsip WHERE wp_pollsq.pollq_id = wp_pollsip.pollip_qid);
    ## Update voter count on questions
    UPDATE wp_pollsq SET pollq_totalvoters = (SELECT COUNT(DISTINCT pollip_ip) FROM wp_pollsip WHERE wp_pollsq.pollq_id = wp_pollsip.pollip_qid);
    ## Update vote count on answers
    UPDATE wp_pollsa SET polla_votes = (SELECT COUNT(*) FROM wp_pollsip WHERE wp_pollsa.polla_aid = wp_pollsip.pollip_aid);

    4. Bug: When questions or answers are too long, the poll management page simply cuts the text off without warning or notice. Perhaps put a size limit on the textbox also?

    5. A do_action API hook for the “voting” event would be very, very useful. In other words, let a site owner or another plugin author be able to write a third-party function (add_action) that fires when someone casts a vote. The third party function, for example, might use a Google Analytics’ _trackPageview for further analysis. (Though this suggestion sounds complicated, it quite isn’t.)

    6. [Nice to Have] Speaking of Analytics, have a Poll Analytics as a dashboard widget: Popular polls this week, Number of votes recorded today, etc. To save on PHP memory, put the code for this on a separate php file that is only require_onced on admin pages.

    7. [For version 3.5??] Surveys. A survey is a group of two or more poll questions (ordered by pollq_id) that share one Vote button. I’ve begun work on this and can share with you what I’ve got.

Viewing 1 replies (of 1 total)
  • Hi Maybe you could post it in, I seldom check here.

    1) 4 is too much, currently it is using 2, at most 3 only.
    2) I will do it, in the next update.
    3) I shall set it to 2,000 and see how it goes. I afrarid if I remove the limit, it will hang the browser because too much data to load.
    4) I don’t get what you mean by that, where is the textbox located at?
    5) Good idea
    6) Good idea
    7) I will still stick to polls, since after all this is a poll plugin.

    PS: Please post it in so that I can consolidate the changes I have to make =) Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: WP-Polls] Some suggestions and ideas for version 3’ is closed to new replies.