ashrafuzzaman / query_report Goto Github PK
View Code? Open in Web Editor NEWThis is a gem to help you to structure common reports of you application just by writing in the controller
License: MIT License
This is a gem to help you to structure common reports of you application just by writing in the controller
License: MIT License
many of my reports have common columns:
def future_report
check_auth
requests = Request::where("status = 'future'").order('date DESC')
reporter(requests) do
column :user_id
column "user name" do |request|
begin
@user_profile = User.find(request[:user_id])
"#{@user_profile.first_name} #{@user_profile.last_name}"
rescue
"user no longer registered"
end
end
column :driver_id
column :vehicle_id
column :status
column :from
column :to
column :rate
column :passengers
column :luggage
column :comment
column :reserve_number
column :promo_code_id
column :payment_options
column :time
column :distance
column :route
column :eta
column :booked
column :start
column :end
column :real_time
column :cancelled
column :partner_id
column :cancelled_user_id
end
end
def driver_report
check_auth
requests = Request.select("requests.*, concat(user_profile.first_name, ' ',user_profile.last_name) as driver_name")
.from("requests, user_profile")
.where("driver_id is not null and user_profile.user_id = requests.driver_id")
reporter(requests.scoped) do
filter :booked, type: :date, default: [1.day.ago.to_date.to_s(:db), Date.current.to_s(:db)]
filter :driver_name, type: :text do |query, name|
query.where("user_profile.first_name like ? or user_profile.last_name like ?", "%#{name}%", "%#{name}%")
end
column :user_id
column :driver_name
column :driver_id
column :vehicle_id
column :status
column :from
column :to
column :rate
column :passengers
column :luggage
column :comment
column :reserve_number
column :promo_code_id
column :payment_options
column :time
column :distance
column :route
column :eta
column :booked
column :start
column :end
column :real_time
column :cancelled
column :partner_id
column :cancelled_user_id
end
end
is there a way i can encapsulate the columns in a variable or something? what would it look like?
I noticed by just putting a filter
you get a search form.. However I'm not sure how to control the action of that search form (ie where the search form directs to)..
so let's say i'm in admin/reports/daily.. if i hit search it automatically goes to admin/reports.. where do i control this kind of routing/action for the search form?
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
the way query report is made is that it auto generates a date filer (it uses bootstrap-datepicker).. i will need to add a time picker as well.. there is a gem for that as well.. how can i do this? will i have to build my own gem?
I noticed that in your demo project gemfile, there aren't any dependencies for gems that generate pdfs (ie gem 'wkhtmltopdf-binary'
gem 'wicked_pdf'
gem 'pdfkit').. which makes me wonder how does query_report generate pdfs?
so something like
filter :driver_name, type: :text, default: :all
Hello,
Thanks for the wonderful plugin.
I would like to know whether there is support to generate report using raw SQL.
Can we use query using Active Record find_by_sql() method?
Thanks,
Let say I have a table with column AMOUNT and TYPE. Amounts 10,20,50. Type 1,1,2
Let say I want in a column the sum of amounts for which type is 1. Result should be 30.
And in another column sum of amounts for which type is 2. Result should be 50.
In controller I can apply sum in this way sum(AMOUNT) as total_amount and then call column :total_amount.
But I am unable to apply the condition where type = 1.
I understand that it can't be done through a scope or new method as column refers to db tables not active records.
Is this possible at all?
Can this be used this with Sinatra or other non-rails frameworks?
thx!
how do i put a placeholder in the search field? right now i can only put a default value:
filter :driver_name, type: :text, default: "enter driver name"
i would like to do something like this
filter :driver_name, type: :text, placeholder: "enter driver name"
right now if i do the above i get this in the placeholder:
placeholder="translation missing: en.query_report.filters.driver_name.contains"
Does this not work with rails 4?
I added gem "query_report", "~> 1.1.2"
to my Gemfile and did bundle install
but my rails app isn't recognizing it. It says cannot load such file -- query_report/helper
.
the date works just fine in filtering.. but filtering by driver_name
doesn't make a difference:
requests = Request.select("requests.*, concat(user_profile.first_name, ' ',user_profile.last_name) as driver_name")
.from("requests, user_profile")
.where("driver_id is not null and user_profile.user_id = requests.driver_id")
reporter(requests.scoped) do
filter :booked, type: :date, default: [1.day.ago.to_date.to_s(:db), Date.current.to_s(:db)]
filter :driver_name, type: :text
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.