Skip to content

Instantly share code, notes, and snippets.

@atopal
Created October 4, 2012 09:00
Show Gist options
  • Save atopal/3832348 to your computer and use it in GitHub Desktop.
Save atopal/3832348 to your computer and use it in GitHub Desktop.
helpful votes from browsing for Spanish
SELECT positive_search_votes.date_created as created_date, positive_search_votes.votes, all_search_votes.votes, (positive_search_votes.votes/all_search_votes.votes*100) as helpful_votes
FROM
(
SELECT DATE(`wiki_helpfulvote`.`created`) as date_created, count(*) as votes
FROM `wiki_helpfulvote`
JOIN `wiki_revision` ON `wiki_helpfulvote`.`revision_id`=`wiki_revision`.`id`
JOIN `wiki_document` ON `wiki_revision`.`document_id`=`wiki_document`.`id`
JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvote`.`created` BETWEEN '2012-01-01 0:0:0' AND '2012-09-30 23:59:59'
AND `wiki_document`.`locale` LIKE 'es'
AND `wiki_helpfulvote`.`user_agent` NOT LIKE '%bot%'
AND `wiki_helpfulvote`.`helpful` ='1'
AND `wiki_helpfulvotemetadata`.`key` LIKE 'referrer'
AND `wiki_helpfulvotemetadata`.`value` LIKE '%support.mozilla.org%'
AND `wiki_helpfulvotemetadata`.`value` NOT LIKE '%questions%'
GROUP by DATE(`wiki_helpfulvote`.`created`)
) as positive_search_votes
JOIN
(
SELECT DATE(`wiki_helpfulvote`.`created`) as date_created, count(*) as votes
FROM `wiki_helpfulvote`
JOIN `wiki_revision` ON `wiki_helpfulvote`.`revision_id`=`wiki_revision`.`id`
JOIN `wiki_document` ON `wiki_revision`.`document_id`=`wiki_document`.`id`
JOIN `wiki_helpfulvotemetadata` ON `wiki_helpfulvote`.`id`=`wiki_helpfulvotemetadata`.`vote_id`
WHERE `wiki_helpfulvote`.`created` BETWEEN '2012-01-01 0:0:0' AND '2012-09-30 23:59:59'
AND `wiki_document`.`locale` LIKE 'es'
AND `wiki_helpfulvote`.`user_agent` NOT LIKE '%bot%'
AND `wiki_helpfulvotemetadata`.`key` LIKE 'referrer'
AND `wiki_helpfulvotemetadata`.`value` LIKE '%support.mozilla.org%'
AND `wiki_helpfulvotemetadata`.`value` NOT LIKE '%questions%'
GROUP by DATE(`wiki_helpfulvote`.`created`)
) as all_search_votes
ON positive_search_votes.date_created=all_search_votes.date_created;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment