streak-python

Library for calculating win/loss streaks using Redis as a backend
Download

streak-python Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • David Czarnecki
  • Publisher web site:
  • https://github.com/czarneckid/

streak-python Tags


streak-python Description

streak is a Python library for calculating win/loss streaks. It uses Redis as its backend for collecting the data. This is a Python port of the original (https://github.com/czarneckid/streak) Ruby gem.Usagepython>>> from streak import Streak>>> streak = Streak()>>> streak.aggregate('david', 3)>>> streak.aggregate('david', -2)>>> streak.aggregate('david', 5)>>> streak.aggregate('david', -1)>>> statistics = streak.statistics('david')>>> print statistics{'losses_streak': 2, 'wins_streak': 5, 'wins': 0, 'losses_total': 3, 'losses': 1, 'wins_total': 8, 'total': 11}>>> streak.reset_statistics('david')>>> statistics = streak.statistics('david')>>> print statistics{'losses_streak': 0, 'wins_streak': 0, 'wins': 0, 'losses_total': 0, 'losses': 0, 'wins_total': 0, 'total': 0}>>>You can also configure the keys used in Redis:python>>> streak = Streak(dict( namespace = 'streak', positive_key = 'kills', positive_total_key = 'kills_total', positive_streak_key = 'kills_streak', negative_key = 'deaths', negative_total_key = 'deaths_total', negative_streak_key = 'deaths_streak', total_key = 'total'))If you need to set the Redis instance to something other than `localhost:6379/0`, you can do:pythonstreak.redis = redis.StrictRedis(host = 'some.host', port = 6379, db = 7)Product's homepage


streak-python Related Software