• Stars
    star
    100
  • Rank 340,703 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 13 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Punching Bag is a hit tracking plugin for Ruby on Rails that specializes in simple trending

Punching Bag Build Status

Punching Bag is a hit tracking plugin for Ruby on Rails that specializes in simple trending.

Features

  • Total hit count
  • Hit counts for the last day, week, month, etc.
  • Simple trending based on most hits in the last day, week, month, etc.
  • Rake task to group old hit records for better performance
  • ActsAsTaggableOn integration for trending tags/topics support
  • Voight-Kampff integration for bot checking

Requirements

  • An existing Rails app
  • Ruby >= 2.3

Installation

In your Gemfile add:

gem "punching_bag"

In the terminal run:

bundle install
rails g punching_bag
rake db:migrate

In your model add:

acts_as_punchable

Usage

Tracking hits in your controller

class PostsController < ApplicationController
  def show
    @post.punch(request)
  end
end

Getting a total hit count in your view

@post.hits

Getting a hit count for a time period in your view

@post.hits(1.week.ago)

Getting a list of the five all-time most hit posts

Post.most_hit

Getting a list of the 10 most hit posts for the last 24 hours

Post.most_hit(1.day.ago, 10)  # limit is 5 by default, pass nil for no limits

Sorting posts based on all time hit count

Post.sort_by_popularity('DESC')   # DESC by default, can also use ASC

Getting a hit count on a tag for the last month

tag.hits(1.month.ago)

Getting a list of the 10 most hit tags in the last week

ActsAsTaggableOn::Tag.most_hit(1.month.ago, 10)

Compressing old hit records to improve performance
The default settings combine records by day if they're older than 7 days, by month if they're older than 1 month and by year if they're older than 1 year

rake punching_bag:combine

Compressing old hit records using custom settings
This time we'll combine records by day if they're older than 14 days, by month if they're older than 3 months and by year if they're older than 2 years

rake punching_bag:combine[14,3,2]

Notes

  • The punching_bag:combine rake tasks is not run automatically. You'll have to run it manually or add it as a cron job.
  • The punching_bag:combine rake task can take a while depending on how many records need to be combined.
  • Passing the request object to the punch method is optional but without it requests from bots, crawlers and spiders will be tracked.
  • See the Voight-Kampff documentation if you'd like to customize the list of user-agents considered bots.
  • The tag related features will only work if you have ActsAsTaggableOn installed and enabled on the same models as Punching Bag.

More Repositories

1

turnout

Turnout makes it easy to put Rack apps into maintenance mode
Ruby
577
star
2

Voight-Kampff

Voight-Kampff is a Ruby gem that detects bots, spiders, crawlers and replicants
Ruby
183
star
3

rack-cas

Rack-CAS is simple Rack middleware to perform CAS client authentication.
Ruby
149
star
4

chef-cookbooks

Cookbooks used by Biola University
Ruby
17
star
5

chef-omnibus_updater_windows

Chef cookbook for updating the chef-client installation on Windows
Ruby
6
star
6

adfs_theme

Customizations for SAML login screen
CSS
5
star
7

chef-zfs_linux

Chef cookbook for deploying ZFS on Linux
Ruby
5
star
8

appdoc

Allows you to add documents and documentation to your app
JavaScript
4
star
9

port-a-query

Simple ruby helper for generating portable SQL expressions.
Ruby
3
star
10

ask

Allow your site's maintainers to easily create forms.
Ruby
3
star
11

action_links

Quick and painless action links for your rails applications
Ruby
3
star
12

chronic_ping

Rails engine that uses ajax and chronic to parse date text_fields
Ruby
2
star
13

feed_satisfaction

Simple Ruby on Rails engine that allows you to easily add a Get Satisfaction feedback page to your app
Ruby
2
star
14

digital_signage_mac_client

This mac application is a simple WebView wrapper that is used with our digital signage web application.
Objective-C
2
star
15

humanity

Mix in Humanity and get common user model functionality
Ruby
2
star
16

chef-sssd_ad

Chef cookbook to set up AD authentication on Ubuntu systems using SSSD
Ruby
2
star
17

trogdir-models

A shared models gem for the Trogdir directory
Ruby
1
star
18

bbconnect-sync

Syncs contacts from Banner to Blackboard Connect
Ruby
1
star
19

biola-link-headers-footers

static content used by biola-csm.symplicity.com
CSS
1
star
20

event-publisher

Ruby
1
star
21

styleguide

Styleguide for biola frontend websites.
JavaScript
1
star
22

biola.github.io

1
star
23

chef-vsphere_perl_sdk

Chef cookbook for deploying the VMware Perl SDK
Ruby
1
star
24

sinatra-boilerplate

Boilerplate code for starting a simple Sinatra app.
Ruby
1
star
25

carrierwave-roz

Carrierwave storage plugin for the Roz assets API
Ruby
1
star
26

libstats

Fork of http://code.google.com/p/libstats/
PHP
1
star
27

buweb-api-client

Tie in for biola-web-api
Ruby
1
star
28

gatekeeper

User account creation and management app
Ruby
1
star
29

banner-syncinator

Sync data between Banner and Trogdir API
Ruby
1
star
30

biola-logs

Standardized, opinionated log formatting
Ruby
1
star
31

chef-mysql_management

Chef cookbook for managing MySQL databases, users, and backups
Ruby
1
star
32

csm-sync

Automated export of student and alumni data to Symplicity CSM
Ruby
1
star
33

biola-deploy

A collection of deployment rake tasks
Ruby
1
star
34

google-syncinator-api-client

API consuming models for the Google Syncinator project
Ruby
1
star
35

chef-oracle_instant_client

Chef cookbook for deploying Oracle Instant Client
Ruby
1
star
36

ta-nexentastor

1
star
37

trogdir-api

RESTful API for the trogdir directory
Ruby
1
star
38

chef-opsview

Chef cookbook for deploying Opsview Core
Ruby
1
star
39

chef-dns_caching

A Chef cookbook for managing DNS caching
HTML
1
star
40

biola-frontend-toolkit

A gem of generic tools and helpers for building Biola apps.
SCSS
1
star
41

mobile-student-app

Mobile student app using angular and ionic
JavaScript
1
star