{"id":13878496,"url":"https://github.com/quadule/activerecord-postgresql-cube","last_synced_at":"2025-04-30T15:14:02.564Z","repository":{"id":53599661,"uuid":"63524581","full_name":"quadule/activerecord-postgresql-cube","owner":"quadule","description":"ActiveRecord support for the PostgreSQL cube data type.","archived":false,"fork":false,"pushed_at":"2021-03-22T05:33:22.000Z","size":13,"stargazers_count":8,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T07:23:02.569Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quadule.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-17T09:39:11.000Z","updated_at":"2023-05-23T18:52:51.000Z","dependencies_parsed_at":"2022-09-02T01:11:49.410Z","dependency_job_id":null,"html_url":"https://github.com/quadule/activerecord-postgresql-cube","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quadule%2Factiverecord-postgresql-cube","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quadule%2Factiverecord-postgresql-cube/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quadule%2Factiverecord-postgresql-cube/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quadule%2Factiverecord-postgresql-cube/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quadule","download_url":"https://codeload.github.com/quadule/activerecord-postgresql-cube/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229510771,"owners_count":18084444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:51.516Z","updated_at":"2024-12-13T08:08:38.571Z","avatar_url":"https://github.com/quadule.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# activerecord-postgresql-cube\n\nAdds support to ActiveRecord for the PostgreSQL cube data type.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activerecord-postgresql-cube'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install activerecord-postgresql-cube\n\n## Usage\n\nMake sure you have the cube extension enabled on your database, then add and index a column with a `cube` type:\n\n```ruby\nenable_extension \"cube\"\nadd_column :things, :features, :cube\nadd_index :things, :features, using: \"gist\"\n```\n\nDefine optional accessor methods:\n\n```ruby\nclass Thing \u003c ActiveRecord::Base\n  cube_attributes :features, :fluffiness, :crunchiness, :hotness, :dryness\nend\n\n# These are equivalent:\nThing.new(features: [1.0, 0.0, 0.5, 0.2])\nThing.new(fluffiness: 1.0, crunchiness: 0.0, hotness: 0.5, dryness: 0.2)\n```\n\nQuery ordered by cube distance to find similar results.\n\n```ruby\n# Seed with some random values:\n100.times { Thing.create(features: Array.new(4) { rand }) }\n\n# Query directly:\nmy_favorite_thing = Thing.by_cube_distance(:features, [1.0, 0.0, 0.5, 0.2]).first\n# =\u003e #\u003cThing id: 39, features: [0.832089176888876, 0.192166292526192, 0.56526526018018, 0.0925453162946783]\u003e\nmy_favorite_thing.distance # =\u003e 0.284478455665301\n\n# Or by distance from an existing record:\nrecommended_thing = my_favorite_thing.similar_by_cube_distance(:features).first\n# =\u003e #\u003cThing id: 691, features: [0.61796879992257, 0.249908423662009, 0.593267501286819, 0.0877211312590144]\u003e\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/quadule/activerecord-postgresql-cube.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquadule%2Factiverecord-postgresql-cube","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquadule%2Factiverecord-postgresql-cube","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquadule%2Factiverecord-postgresql-cube/lists"}