When you create votes in the votingapi_vote table with different tags for the same node, for some reason VotingAPI doesn't do anything with them. The votingapi_cache table remains empty and averages are not calculated. Issue came up while using Fivestar.

Issue also discussed here in the Fivestar project:
http://drupal.org/node/234543
http://drupal.org/node/148150#comment-563526

CommentFileSizeAuthor
#4 votingapi.no-caching.patch468 bytesbryanzera

Comments

greg.harvey’s picture

UPDATE:

If I change the VotingAPI settings from "Tally results whenever a vote is cast" to "Tally results at cron-time" and run cron then everything is fine. Looks like there is a little bug hiding in the "Tally results whenever a vote is cast".

greg.harvey’s picture

Title: votingapi_cache table is empty so no average vote available » votingapi_cache table is not updated in "Tally results whenever a vote is cast" mode
xqi’s picture

i am having the same problem.

bryanzera’s picture

Status: Active » Needs review
StatusFileSize
new468 bytes

The votingapi_add_vote() function doesn't try to recalculate the cache like it is purported to do.

Here's a patch to make it recalculate on new votes (when Vote tallying is not set to occur on cron-only)

eaton’s picture

Status: Needs review » Closed (works as designed)

The votingapi_add_vote() function doesn't try to recalculate the cache like it is purported to do.

votingapi_add_vote() isn't purported to do that at all; it exists so that modules can insert specific votes in various combinations, then manually call the votingapi_recalculate_votes() function when they've completed. If we recalculated every time we added ONE vote, complex votes with multiple criteria would thrash the database badly.

greg.harvey’s picture

Status: Closed (works as designed) » Active

Wait a second, ignoring the patch may be mis-using a VotingAPI function, you can't set this whole issue to "by design". The original issue is not fixed thus is still an open issue. For clarity, I'll restate the EXISTING and ACTIVE issue:

When VotingAPI settings are set to "Tally results whenever a vote is cast" and you have any votes using axes other than the default, VotingAPI fails to acknowledge and the votingapi_cache table remains empty (results are *never* tallied).

It seems to be a bug. If it was never intended to work, the whole "axes" feature should be removed as an option, but it seems unlikely as it functions fine when the scripts run at cron and anyway, removing axes would seriously limit the API leaving you with one vote per node.

eaton’s picture

Status: Active » Closed (works as designed)

Wait a second, ignoring the patch may be mis-using a VotingAPI function, you can't set this whole issue to "by design". The original issue is not fixed thus is still an open issue. For clarity, I'll restate the EXISTING and ACTIVE issue:

When VotingAPI settings are set to "Tally results whenever a vote is cast" and you have any votes using axes other than the default, VotingAPI fails to acknowledge and the votingapi_cache table remains empty (results are *never* tallied).

That's incorrect. The difference is between the broad "votingapi_set_votes()" function, which has less flexibility but automatically handles the full VotingAPI workflow, including vote recalculation, and the "votingapi_add_vote()" function, which offers more control to modules that need it BUT doesn't automatically trigger recalculation.

Modules that use votingapi_add_vote() are implicitly taking on the responsibility of calling votingapi_recalculate_results() when they're done. If they use votingapi_set_votes() instead, it will be handled automatically. I reiterate: this is by design, and the problem is that a module is adding votes one-by-one but never calling votingapi_recalculate_results().

That's why setting it to recalculate on cron worked perfectly -- all that does is look for content that's had votes cast since the last cron run, and calls votingapi_recalculate_results() on them.

greg.harvey’s picture

Ok - thanks for the clarification - back to the Fivestar team then!! =(