Git Product home page Git Product logo

read_activity's Introduction

ReadActivity Build Status

Manages read activities.

This gem supports to get read/unread status (including read_at), read/unread users for a specific readable, etc.

Installation

Add this line to your application's Gemfile:

gem 'read_activity'

And then execute:

$ bundle

Or install it yourself as:

$ gem install read_activity

Execute to generate a migration for creating ReadActivity model:

rails generate read_activity

Usage example

class User < ActiveRecord::Base
  acts_as_reader
end

class Article < ActiveRecord::Base
  acts_as_readable
end

user = User.create!
article = Article.create!

user.read!(article)
# or article.read_by!(user)

user.read?(article) # == true
# or article.read_by?(user) == true

user.read_at(article)
# or article.read_by_at(user)

article.readers # == [user]
# or user.read_articles == [article]
# user.read_#{reader_table_name} (the plural form)

article.unreaders # == []
# or user.unread_articles == []
# user.unread_#{readable_table_name} (the plural form)

reader = article.readers.first
reader.read_at # no required params when you have fetched readers using #readers

read_article = user.read_articles.first
read_article.read_by_at

User.find_who_read(article)
User.find_who_unread(article)

Article.find_read_by(user)
Article.find_unread_by(user)

Contributing

  1. Fork it ( https://github.com/[my-github-username]/read_activity/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

read_activity's People

Contributors

angdev avatar

Stargazers

Brendon Murphy avatar Dmitry Shulgachik avatar Vitaly Pavlitsky avatar  avatar Alex Musayev avatar Serhii Ponomarov avatar QUANON avatar Amit Erandole avatar DJ Patterson avatar Igor Zubkov avatar Fon avatar Dmitriy Plekhanov avatar Shenouda Bertel avatar Moojin Chae avatar Igor Victor avatar Adam Kirkwood avatar Walter Lee Davis avatar  avatar Vladimir Vinnikov avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

vishnuvntcr

read_activity's Issues

order_by_read_at 함수 추가하기

현재 문제가 될 수 있는 부분은 unreaders 의 경우는 AS를 써서 테이블 alias를 쓰고 있어서 처리가 깔끔하지 못하다는 점인데 AS를 nested select로 바꾸면 문제는 없을지 찾아보고 고치자.

read_at N+1 problem

Need to eager load read_activity_marks to solve N+1 problem. need to store binding value [reader-readable].

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.