Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plan to support mongoid? #1

Open
mustela opened this issue Jun 5, 2017 · 2 comments
Open

Any plan to support mongoid? #1

mustela opened this issue Jun 5, 2017 · 2 comments

Comments

@mustela
Copy link
Contributor

mustela commented Jun 5, 2017

No description provided.

@t27duck
Copy link
Owner

t27duck commented Jun 17, 2017

Currently not at this time. I mainly work with relational databases which work well with aggregating data.

niborg added a commit to niborg/active_reporting that referenced this issue Apr 20, 2018
Specify rescue from LoadError for ransack
@germanotm
Copy link
Contributor

I don't think there is need for a gem for mongo database.
The mongo api already allows you to use $match for filters and $group for dimensions.

Take a look at this piece of code a use another day:

month_start = Date.today.beginning_of_month
month_end = Date.today.end_of_month

filters = {
  "created_at" => {
      "$gte" => month_start,
      "$lt" => month_end
}}

dimensions = { "storage_type" => "$storage_type", "month" => { "$month" => "$created_at" }

storage_size = Storage.collection.aggregate([
  {"$match" => filters },
  {"$group" => { 
    "_id" =>  dimensions }, 
    "value" => { "$sum" => "$value" }}
  }
])

So, at report view, you make a form to select which filters and which dimensions you need. Is indeed much more easy than doing the same thing with ActiveRecord.
You may need to duplicate data to workaround join tables, don't know how it could be made another way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants