Coder Social home page Coder Social logo

humzashah / convenient_grouper Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 26 KB

Use Ruby hashes to group database table rows through ActiveRecord.

Home Page: https://rubygems.org/gems/convenient_grouper

License: MIT License

Ruby 99.49% Shell 0.51%

convenient_grouper's People

Contributors

humzashah avatar

convenient_grouper's Issues

More extensive tests

Currently the tests are checking the string outputs of a few methods. Modify this so that a real database is involved and the tests verify the records that are being fetched, rather than strings being outputted.

Any one of the following should be sufficient, since the where and group are treated the same: MySQL, PostgreSQL, or SQLite

ALSO: use Minitest rather than RSpec.

Auto-name groups

Accept array of values, arrays, and ranges and auto-name the groups e.g.

Employee.group(id: [1, 2, [3,4], 6..9])

should become something like:

Employee.group(id: {a: 1, b: 2, c: [3,4], d: 6..9})

add option to disable default group

Disable the default group so that the following commands:

Event.group(date: {not_on_date: ">= #{some_date}"}).count

yield either an empty hash or a hash with only one key which is not_on_date

Option to auto-restrict records to grouping options

Employee.group({age: {first: 18}}, restrict: true)

should translate to

Employee.where(age: 18).group(age: {first: 18)

Similarly

Employee.group({age: {first: 18, second: [19, 20], third: 25..30}}, restrict: true)

should restrict the query to employees who are of ages 18, 19, 20, or between 25 and 30.

Improper range error when min and max are the same

Technically speaking, the range is not invalid, it's just equivalent to group_name: range.min.

I'm using the gem and generating the groups dynamically and ran into this. It would be nice not to have to change from a range to a value.

So I suggest changing https://github.com/humzashah/convenient_grouper/blob/master/lib/convenient_grouper/hash_converter.rb#L120 to be valid = min && max && (min <= max), what do you think?

I can submit a PR, please let me know.

Thank you!

Rachel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.