Created
December 13, 2018 12:56
-
-
Save apetrov/e130794f8c2fbe917f00f5b9b18e0e39 to your computer and use it in GitHub Desktop.
This file contains 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
select [user_id, sum(payout),sum(fee).as(fee)], from: :transactions do | |
join :users do | |
users :id | |
transactions :user_id | |
end | |
groupby :user_id | |
where { user_id [1,2,3] } | |
where { fee > 40 } | |
order "sum(payout)", :desc | |
end | |
# Thinking of building a readable alternative for AREL. | |
# Must have feature is to make it composable in a similar way but | |
# Avoid a pit-fall of the over-complicated syntax. | |
# I haven't fininshed with the final version of the syntax yet, | |
# But once it's done, that's a fairly straightforward to make it work. | |
# also stumble across a similar project (10 year old!) | |
# https://github.com/semenov/boroda | |
# but it lack composablity and syntax could have been better. | |
# | |
# one more thing from my experience: | |
# in 99.9% of complicated queries, it's all about producing select statements for | |
# a reporting purposes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment