Ruby on Rails对象报告 [英] Ruby on Rails object reporting

查看:159
本文介绍了Ruby on Rails对象报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个ruby应用程序,它有大量不同的对象。作为此应用程序的一部分,我想添加一个报告引擎,允许用户为应用程序中的几乎任何变量创建自定义报告,例如,他们可以创建一个报告,显示客户有多少百分比的电话号码,街道名称以E开头的供应商的绝对数量。他们应该能够在应用程序中创建任何关于数据的报告,而不管它是多么模糊,而不需要依赖它已经在应用程序中创建了。



我的问题是:如何开始创建一个允许这种情况发生的结构?是否需要指定所有可能用作报告一部分的可能变量(例如,我需要指定 customers.count 客户.email_address suppliers.addresses.street_name 都是可用于上述示例的报告引擎的变量),或者这些变量可能会自动?



如果需要指定变量,最好的方法是什么?



我已经在这里搜索了一些资源,但还没有发现任何 - 如果有人可以推荐一个来源,也将不胜感激。



谢谢!

解决方案

考虑自己警告,这可能违反YAGNI。我强烈建议您首先为用户想要的最常见的报告类型构建报告,以便您可以使其可用和漂亮。这样做在抽象层次是一个数量级更复杂,是容易出错,如果你不小心可能会导致一些安全问题,将很难做出漂亮的报告,而不是通用的查找。 / p>

也就是说,看看像 Active Admin ,它提供自定义过滤器和数据导出。你应该能够添加自定义范围,让它做你想要的,但如果它仍然没有,那么查看实现应该给你一个很好的想法涉及。


I am currently developing a ruby application that has a large number of different objects. As part of this application, I would like to add a reporting engine that allows a user to create custom reports on virtually any variable within the application - for example, they could create a report that shows what percentage of customers have a telephone number, or the absolute number of suppliers whose street name starts with an E. The point is, they should be able to create any report on the data in the app, regardless of how obscure, without needing to rely on it having been created in the application already.

My question is: how do I start creating a structure that allows this to happen? Will it be necessary to specify all possible variables that could be used as part of a report (e.g. I would need to specify that customers.count, customers.email_address and suppliers.addresses.street_name are all variables available to the reporting engine for the example above), or could these somehow be made available automatically?

If it is necessary to specify the variables, what would be the best way to do this?

I have searched for some resources on this, but have not yet found any - if anyone can recommend a source, it would also be appreciated.

Thanks!

解决方案

Consider yourself warned that this likely violates YAGNI. I would highly recommend building reports first for the most common types of reports your users will want, so that you can make them usable and pretty. Doing this at the abstract level is an order of magnitude more complex, is error prone, may lead to some security issues if you're not careful, and will be difficult to make pretty reports rather than generic looking ones.

That said, take a look at something like Active Admin, which provides custom filters and data exports. You should be able to add custom scopes to have it do what you want, but if it still doesn't, then looking at the implementation should give you a good idea of what's involved.

这篇关于Ruby on Rails对象报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆