provide script and documentation to rebuild the votingapi cache

greggles - February 24, 2009 - 23:07
Project:Voting API
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

I found myself in a situation where I needed to rebuild the votingapi_cache table (it got deleted). So, here's a script which will do it and some clean ups to README.txt while we're at it.

AttachmentSize
votingapi_rebuild_cache.php_.txt577 bytes
votingapi_rebuild_cache.patch2.77 KB

#1

greggles - February 24, 2009 - 23:07
Status:active» needs review

#2

moshe weitzman - February 25, 2009 - 06:21
Status:needs review» reviewed & tested by the community

We're using this script on Economist so I'll RTBC it.

I like this change in README: +VotingAPI requires Drupal.

#3

stewsnooze - February 25, 2009 - 10:25

subscribe

#4

Junro - May 16, 2009 - 19:42

subscribe :)

#5

Scott Reynolds - May 17, 2009 - 00:31
Status:reviewed & tested by the community» needs review

So orginal patch works, but this attached patch is a "I think this is a better approach, no offense" patch. This patch makes the operation Batch API'd and adds a form button to the votingapi settings page. Click the button and rebuild your cache.

I have tested it with a combination of about 100,000 votes on a mixture of nodes, comments, and users

AttachmentSize
votingapi_batch.patch 5.92 KB

#6

greggles - May 17, 2009 - 16:16

I think the warning that it could take a long time should be on the main form in addition to the confirmation form. People generally ignore text on confirm forms.

Other than that, shell scripts are easier to write and less likely to be run by accident. I'm not sure this needs to be truly "hard to run by accident" so I see this as an improvement. Didn't test or do a thorough review of the code, though..

#7

Scott Reynolds - May 17, 2009 - 17:43

Also think that i probably should do a batch_set() for each content type. Removes a lot of the bookkeeping in there.

No harm in adding the warning message again.

#8

Scott Reynolds - May 18, 2009 - 04:25

attached patch does the two afore mentioned things.
1.) adds the message to the button
2.) uses an operation per content_type in the batch api call

Interestingly,

<?php
$form
['results']['help'] = array(
   
'#prefix' => '<div>',
   
'#type' => 'markup',
   
'#value' => t('This action rebuilds all voting results, and may be a lengthy process.'),
   
'#attributes' => array('class' => 'description'),
   
'#suffix' => '</div>',
  );
?>

didn't work even though 'markup' is listed to respect #attributes: http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...

@eaton ^^ ?

AttachmentSize
votinapi_batch.patch 6.36 KB

#9

Junro - May 18, 2009 - 11:45

Hi,

just tried the last patch #8 but He doesn't work for me.

I have in /admin/settings/votingapi/rebuild the button "Rebuild all Voting Results" but when I click on it, the page reload without effects. I don't have anything that confirms any changes.

Anyway Voting results is not rebuilt.

And what about 2.) uses an operation per content_type in the batch api call ?
I can't choose node type.

#10

Scott Reynolds - May 18, 2009 - 16:13

pretty strange. When you run this query: SELECT DISTINCT(content_type) FROM votingapi_vote does it return anything? Is your votingapi_vote table empty?

#11

Junro - May 18, 2009 - 20:10

My content type is "fiche"

When I run this query: SELECT DISTINCT(fiche) FROM votingapi_vote, it return me:

Erreur

requête SQL:

SELECT DISTINCT (
fiche
)
FROM votingapi_vote
LIMIT 0 , 30

MySQL a répondu:
#1054 - Unknown column 'fiche' in 'field list'

I'm not a big expert in SQL

#12

Scott Reynolds - May 19, 2009 - 01:16

right, you need to run this query exactly
SELECT DISTINCT(content_type) FROM votingapi_vote

Not
SELECT DISTINCT(fiche) FROM votingapi_vote

#13

Junro - May 19, 2009 - 01:20

oh ok, sorry

here the results:

Affichage des enregistrements 0 - 29 (1 306 total, Traitement en 0.0003 sec.)

SELECT DISTINCT (
content_type
)
FROM votingapi_vote
LIMIT 0 , 30

#14

Scott Reynolds - May 20, 2009 - 20:35
Status:needs review» needs work

guess its not working still ok.

#15

Junro - June 25, 2009 - 12:42

Nothing new since the last post?

I'm still here to test some patches :) Really needs to rebuild the votingapi cache ^^

#16

Scott Reynolds - June 26, 2009 - 19:40

o duh! you have to clear your menu cache. try existing patch, and visit admin/build/modules first before hitting that button

/me kicks himself forgetting that

#17

Junro - June 30, 2009 - 23:30
Status:needs work» needs review

Perfect! This patch is great! I don't know why it didn't work the first time I apllied it...

#18

Scott Reynolds - June 30, 2009 - 23:34
Status:needs review» reviewed & tested by the community

sweet good to here, marking as reviewed and tested. Im using in other places as well.

#19

Junro - July 1, 2009 - 22:20

Hum that's wird, it didn't work for one vote (maybe more? I haven't see another one yet).

I cleared view cache, performance cache...

What do you call "menu cache"?

you say "and visit admin/build/modules first before hitting that button", I visit admin/build/modules, to do what? Maybe I haven"t carry out all spots before hitting thaht button! lol

#20

Scott Reynolds - July 1, 2009 - 22:27
Status:reviewed & tested by the community» needs work

ok...

The menu callbacks and urls are cached away to the database. This patch adds a new url, so that cache needs to be rebuilt

By going to admin/build/modules, that cache is rebuilt. You don't have todo anything.

But I use devel module to clear the caches (http://drupal.org/project/devel)

#21

Junro - July 1, 2009 - 22:54

Hum ok, I don't really understand why this vote is still here if the votingapi cache has been rebuilt successfully. Is this vote was hidding somewhere? lol

I've got votes from 3 users to erase before launch my website, it was votes for tests.

I will report you if I have some news. :)

ps: I don't use Devel module.

#22

thekayra - October 20, 2009 - 15:56

The patch at #8 worked quite well for me at first glance. Will report if I come accross something strange.

 
 

Drupal is a registered trademark of Dries Buytaert.