{"id":24460901,"url":"https://github.com/proton/mongoid_rateable","last_synced_at":"2025-04-07T11:09:53.812Z","repository":{"id":56884384,"uuid":"1907009","full_name":"proton/mongoid_rateable","owner":"proton","description":"Rating functionality for Mongoid documents","archived":false,"fork":false,"pushed_at":"2023-03-07T01:40:04.000Z","size":154,"stargazers_count":59,"open_issues_count":0,"forks_count":37,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-11T06:46:48.215Z","etag":null,"topics":["mongoid","mongoid-plugin","rails","rating-system","ruby"],"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/proton.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"_proton","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2011-06-16T17:51:48.000Z","updated_at":"2024-06-19T04:07:57.958Z","dependencies_parsed_at":"2024-06-19T04:07:56.396Z","dependency_job_id":"df2fc7cf-7736-49fa-841d-53e73b7f5f6c","html_url":"https://github.com/proton/mongoid_rateable","commit_stats":{"total_commits":179,"total_committers":12,"mean_commits":"14.916666666666666","dds":0.1899441340782123,"last_synced_commit":"cba40785beaf75158adc3d8b9b8fd2fdc7a3b00d"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proton%2Fmongoid_rateable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proton%2Fmongoid_rateable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proton%2Fmongoid_rateable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/proton%2Fmongoid_rateable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/proton","download_url":"https://codeload.github.com/proton/mongoid_rateable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640465,"owners_count":20971557,"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":["mongoid","mongoid-plugin","rails","rating-system","ruby"],"created_at":"2025-01-21T04:15:54.712Z","updated_at":"2025-04-07T11:09:53.787Z","avatar_url":"https://github.com/proton.png","language":"Ruby","readme":"# Mongoid::Rateable\n\nProvides fields and methods for the **rating** manipulation on Mongoid\ndocuments\n\n[![travis CI](https://secure.travis-ci.org/proton/mongoid_rateable.png)](http://travis-ci.org/proton/mongoid_rateable)\n\nLastest version of Mongoid:Rateable requires mongoid 3, 4, 5, 6, 7 and 8.\n\nIf you need a mongoid 2 support, look at mongoid_rateable 0.1.7.\n\n## Support us\n\nhttps://www.patreon.com/_proton\n\n## Installation\n\nAdd to Gemfile:\n\n    gem 'mongoid_rateable'\n\n## Getting Started\n\nSimply use the `rateable` macro from any class that is a Mongoid Document.\n\nThis macro will include `Mongoid::Rateable` into the class and configure the\nrating functionality using the options hash. For any option not present, the\ndefault option value will be used.\n\n    class Post\n      include Mongoid::Document\n\n      rateable range: (-5..7), raters: [User, Admin]\n    end\n\nYou can also set the `default_rater`\n\n    class Post\n      include Mongoid::Document\n\n      # will simply call the 'owner' method to find the default rater\n      # if no rater given when rating\n\n      rateable range: (-5..7), raters: [User, Admin], default_rater: 'owner'\n    end\n\n    class Post\n      include Mongoid::Document\n\n      # if given a block, this will be used as a dynamic way to find\n      # the a rater in case no rater is passed in as the 2nd argument to\n      # the rate method\n\n      rateable range: (-5..7), raters: [User, Admin] do\n        # will by default be rated by the last user\n        # who made a comment to this post!\n        comments.last.user\n      end\n    end\n\nNote: For even more control over the configuration, see the `ClassMethods`\nmodule code in `rateable.rb`.\n\n## Cast Rates\n\nYou can rate by passing an integer and a rater model to the \"rate\" method:\n\n    @post = Post.first\n    @user = User.where(:name =\u003e 'Bill') # or more likely, current_user\n\n    @post.rate 1, @user     # I like this!\n    @post.rate -1, @user    # I don't like this!\n    @post.rate 5, @user     # I LOVE this!\n    @post.rate -10, @user   # Delete it from the Internet!\n\n    # Many users love this!\n    @post.rate 5, @users     # They LOVIN' it!\n\nRates have weight (1 by default)\n\n    @post.rate 5, @user, 3     # Rate @post with weight 3 (@user has high karma)\n    @post.rate 3, @user, 1     # Rate @post with weight 1 (@user has low karma)\n\nYou can unrate by using \"unrate\" method:\n\n    @post.unrate @user\n\nAnd don't forget to save rateable object:\n\n    @post.save\n\nSure, you can rate and save in one function:\n\n    @post.rate_and_save(3, @user)\n    @post.unrate_and_save(@user)\n\n## Additional Functionality\n\nYou'll often want to know if a user already rated post.  Simple:\n\n    @post.rated_by? @user   # True if it rated by user\n\nAnd if someone rated it:\n\n    @post.rated?            # True if it rated by someone\n\nYou can get user mark:\n\n    @post.user_mark(@user)  # Mark or nil (if not rated by user)\n\nOr marks:\n\n    @post.user_marks([@user1, @user2])  # Hash {user.id =\u003e mark}\n\nYou can also get a tally of the number of rates cast:\n\n    @post.rate_count        # Just one so far!\n\nYou can get a total weight of post rates:\n\n    @post.rate_weight        # Just one so far!\n\nAnd you can get the average rating:\n\n    @post.rating            # rates / rate_weight\n\nAnd you can get the average rating without weights (It calculates realtime, so\nit can be slow):\n\n    @post.unweighted_rating # rates without weights / rate_count\n\nAnd you can get the previous rating and delta:\n\n    @post.previous_rating\n    @post.rating_delta      # rating - previous_rating\n\n## Scopes\n\nYou can get rated or unrated posts:\n\n    Post.rated\n    Post.unrated\n\nYou can get posts rated by someone:\n\n    Post.rated_by(@user)\n\nYou can get posts with some rating:\n\n    Post.with_rating(2..5)\n    Post.with_rating(0..10)\n    Post.with_rating(-2..2)\n\nYou can get most rated and highest rated posts: (Sorry, this method doesn't\nwork with embedded documents)\n\n    Post.highest_rated      # 10 (or less) highest rated posts\n    Post.highest_rated(5)   # 5 (or less) highest rated posts\n\n## Contributing to Mongoid::Rateable\n\n*   Check out the latest master to make sure the feature hasn't been\n    implemented or the bug hasn't been fixed yet\n*   Check out the issue tracker to make sure someone already hasn't requested\n    it and/or contributed it\n*   Fork the project\n*   Start a feature/bugfix branch\n*   Commit and push until you are happy with your contribution\n*   Make sure to add tests for it. This is important so I don't break it in a\n    future version unintentionally.\n*   Please try not to mess with the Rakefile, version, or history. If you want\n    to have your own version, or is otherwise necessary, that is fine, but\n    please isolate to its own commit so I can cherry-pick around it.\n\n\n## Copyright\n\nCopyright (c) 2011-2023 Petr Savichev (proton). See LICENSE.txt for further\ndetails.\n","funding_links":["https://patreon.com/_proton","https://www.patreon.com/_proton"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproton%2Fmongoid_rateable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproton%2Fmongoid_rateable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproton%2Fmongoid_rateable/lists"}