Skip to content

Instantly share code, notes, and snippets.

@Getty
Last active December 19, 2015 17:39
Show Gist options
  • Save Getty/5993337 to your computer and use it in GitHub Desktop.
Save Getty/5993337 to your computer and use it in GitHub Desktop.
$self->search({
'token_language_translations.id' => { -not => undef },
'token_domain_id' => $token_domain_id,
'language_id' => $language_id,
-and => [
'me.id' => { -not_in => \@ignore_ids },
'me.id' => { -not_in => $self->search({
'token_language_translation_votes.users_id' => $user_id,
'token_domain_id' => $token_domain_id,
'language_id' => $language_id,
},{
select => 'user_voted.id',
alias => 'user_voted',
join => [ {
token_language_translations => 'token_language_translation_votes'
}, 'token_domain_language' ],
})->as_query},
],
},{
join => [ {
token_language_translations => 'token_language_translation_votes'
}, 'token_domain_language' ],
order_by => { -asc => 'me.created' },
});
SELECT
"me"."id", "me"."token_id", "me"."token_domain_language_id", "me"."notes", "me"."msgstr0", "me"."msgstr1", "me"."msgstr2", "me"."msgstr3", "me"."msgstr4", "me"."msgstr5", "me"."translator_users_id", "me"."data", "me"."created", "me"."updated"
FROM "token_language" "me"
LEFT JOIN "token_language_translation" "token_language_translations"
ON "token_language_translations"."token_language_id" = "me"."id"
LEFT JOIN "token_language_translation_vote" "token_language_translation_votes"
ON "token_language_translation_votes"."token_language_translation_id" = "token_language_translations"."id"
JOIN "token_domain_language" "token_domain_language"
ON "token_domain_language"."id" = "me"."token_domain_language_id"
WHERE ( ( ( 1=1 AND "me"."id" NOT IN (
SELECT "user_voted"."id"
FROM "token_language" "user_voted"
LEFT JOIN "token_language_translation" "token_language_translations"
ON "token_language_translations"."token_language_id" = "user_voted"."id"
LEFT JOIN "token_language_translation_vote" "token_language_translation_votes"
ON "token_language_translation_votes"."token_language_translation_id" = "token_language_translations"."id"
JOIN "token_domain_language" "token_domain_language"
ON "token_domain_language"."id" = "user_voted"."token_domain_language_id"
WHERE ( ( "language_id" = ? AND "token_domain_id" = ? AND "token_language_translation_votes"."users_id" = ? ) )
) ) AND "language_id" = ? AND "token_domain_id" = ? AND "token_language_translations"."id" IS NOT NULL ) )
ORDER BY "me"."created" ASC: '4', '2', '17', '4', '2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment