This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXPLAIN ANALYZE SELECT count(*) FROM users; | |
QUERY PLAN | |
------------------------------------------------------------------------------------------------------------------------ | |
Aggregate (cost=166.31..166.32 rows=1 width=0) (actual time=1720.265..1720.266 rows=1 loops=1) | |
-> Foreign Scan on users (cost=100.00..164.61 rows=3413 width=0) (actual time=2.437..1606.006 rows=118069 loops=1) | |
Total runtime: 1722.674 ms | |
(3 rows) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE VIEW recent_activities AS | |
(SELECT problems.name as title, problems.id as activable_id, problems.user_id, problems.created_at, problems.hashtag, 'Problem' as activable_type FROM problems ORDER BY problems.created_at DESC LIMIT 10) UNION ALL | |
(SELECT ideas_problems.name as title, ideas.id as activable_id, ideas.user_id, ideas.created_at, ideas_problems.hashtag, 'Idea' as activable_type FROM ideas INNER JOIN problems ideas_problems ON (ideas_problems.id = ideas.problem_id) ORDER BY ideas.created_at DESC LIMIT 10) UNION ALL | |
(SELECT tasks.title, task_subscriptions.id as activable_id, task_subscriptions.user_id, task_subscriptions.created_at, tasks.hashtag, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.funders_or_sponsors(opts={}) | |
find_by_sql <<-SQL | |
SELECT * | |
FROM ( | |
(SELECT "users".* FROM "users" WHERE "users"."sponsor" = 't') | |
UNION | |
(SELECT DISTINCT "users".* FROM "users" INNER JOIN "successful_transactions" ON "successful_transactions"."user_id" = "users"."id") | |
) AS t | |
SQL | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GIT | |
remote: git://github.com/rbCAS/casino-activerecord_authenticator.git | |
revision: c159fbaf59b54e945e4be9ddd049e28eaf172ca3 | |
branch: casino3 | |
specs: | |
casino-activerecord_authenticator (3.0.0.pre.1) | |
activerecord (~> 4.1.0) | |
bcrypt (~> 3.0) | |
casino (~> 3.0.0.pre.1) | |
phpass-ruby (~> 0.1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaults: &defaults | |
login_ticket: | |
lifetime: 600 | |
service_ticket: | |
lifetime_unconsumed: 300 | |
lifetime_consumed: 86400 | |
proxy_ticket: | |
lifetime_unconsumed: 300 | |
lifetime_consumed: 86400 | |
frontend: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
# Customize BASH PS1 prompt to show current GIT repository and branch. | |
# by Mike Stewart - http://MediaDoneRight.com | |
# SETUP CONSTANTS | |
# Bunch-o-predefined colors. Makes reading code easier than escape sequences. | |
# I don't remember where I found this. o_O |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Subscription.create/Subscription.update | |
# if subscription.payment_option == "creditcard" | |
# PLAN | |
# SUBUPDATED | |
# SUBVALUE | |
# Invoice.create/Invoice.update | |
# NINVOICES | |
# LINVOICE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def canceled_subscriptions | |
canceled_subscriptions = [] | |
offset = 0 | |
subscriptions = Moip::Subscription.new.load offset | |
while subscriptions.any? | |
subscriptions.each do |subscription| | |
if subscription["status"] == "CANCELED" | |
canceled_subscriptions << subscription["code"] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateViewFacts < ActiveRecord::Migration | |
def up | |
create_view :facts, " | |
SELECT c.id, c.created_at, c.name, c.description_html, c.link, c.mobilization_id, 'campaigns' as relname FROM campaigns c | |
UNION ALL | |
SELECT p.id, p.created_at, p.name, p.description as description_html, p.link, p.mobilization_id, 'problems' as relname FROM problems p;" | |
end | |
def down | |
drop_view :facts |