{ "info": { "author": "Matt Croydon, Mikhail Korobov", "author_email": "mcroydon@gmail.com, kmike84@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "====================================================\ndjango-qsstats-magic: QuerySet statistics for Django\n====================================================\n\nThe goal of django-qsstats is to be a microframework to make\nrepetitive tasks such as generating aggregate statistics of querysets\nover time easier. It's probably overkill for the task at hand, but yay\nmicroframeworks!\n\ndjango-qsstats-magic is a refactoring of django-qsstats app with slightly\nchanged API, simplified internals and faster time_series implementation.\n\n\nRequirements\n============\n\n* `python-dateutil `_ > 1.4, < 2.0\n* `django `_ 1.2+\n\nLicense\n=======\n\nLiensed under a BSD-style license.\n\nExamples\n========\n\nHow many users signed up today? this month? this year?\n------------------------------------------------------\n\n::\n\n from django.contrib.auth.models import User\n import qsstats\n\n qs = User.objects.all()\n qss = qsstats.QuerySetStats(qs, 'date_joined')\n\n print '%s new accounts today.' % qss.this_day()\n print '%s new accounts this week.' % qss.this_week()\n print '%s new accounts this month.' % qss.this_month()\n print '%s new accounts this year.' % qss.this_year()\n print '%s new accounts until now.' % qss.until_now()\n\nThis might print something like::\n\n 5 new accounts today.\n 11 new accounts this week.\n 27 new accounts this month.\n 377 new accounts this year.\n 409 new accounts until now.\n\nAggregating time-series data suitable for graphing\n--------------------------------------------------\n\n::\n\n from django.contrib.auth.models import User\n import datetime, qsstats\n\n qs = User.objects.all()\n qss = qsstats.QuerySetStats(qs, 'date_joined')\n\n today = datetime.date.today()\n seven_days_ago = today - datetime.timedelta(days=7)\n\n time_series = qss.time_series(seven_days_ago, today)\n print 'New users in the last 7 days: %s' % [t[1] for t in time_series]\n\nThis might print something like::\n\n New users in the last 7 days: [3, 10, 7, 4, 12, 9, 11]\n\n\nPlease see qsstats/tests.py for similar usage examples.\n\nAPI\n===\n\nThe ``QuerySetStats`` object\n----------------------------\n\nIn order to provide maximum flexibility, the ``QuerySetStats`` object\ncan be instantiated with as little or as much information as you like.\nAll keword arguments are optional but ``DateFieldMissing`` and\n``QuerySetMissing`` will be raised if you try to use ``QuerySetStats``\nwithout providing enough information.\n\n``qs``\n The queryset to operate on.\n\n Default: ``None``\n\n``date_field``\n The date field within the queryset to use.\n\n Default: ``None``\n\n``aggregate``\n The django aggregation instance. Can be set also set when\n instantiating or calling one of the methods.\n\n Default: ``Count('id')``\n\n``operator``\n The default operator to use for the ``pivot`` function. Can be also set\n when calling ``pivot``.\n\n Default: ``'lte'``\n\n``today``\n The date that will be considered as today date. If ``today`` param is None\n QuerySetStats' today will be datetime.date.today().\n\n Default: ``None``\n\n\nAll of the documented methods take a standard set of keyword arguments\nthat override any information already stored within the ``QuerySetStats``\nobject. These keyword arguments are ``date_field`` and ``aggregate``.\n\nOnce you have a ``QuerySetStats`` object instantiated, you can receive a\nsingle aggregate result by using the following methods:\n\n* ``for_minute``\n* ``for_hour``\n* ``for_day``\n* ``for_week``\n* ``for_month``\n* ``for_year``\n\n Positional arguments: ``dt``, a ``datetime.datetime`` or ``datetime.date``\n object to filter the queryset to this interval (minute, hour, day, week,\n month or year).\n\n* ``this_minute``\n* ``this_hour``\n* ``this_day``\n* ``this_week``\n* ``this_month``\n* ``this_year``\n\n Wrappers around ``for_`` that uses ``dateutil.relativedelta`` to\n provide aggregate information for this current interval.\n\n``QuerySetStats`` also provides a method for returning aggregated\ntime-series data which may be extremely using in plotting data:\n\n``time_series``\n Positional arguments: ``start`` and ``end``, each a\n ``datetime.date`` or ``datetime.datetime`` object used in marking\n the start and stop of the time series data.\n\n Keyword arguments: In addition to the standard ``date_field`` and\n ``aggregate`` keyword argument, ``time_series`` takes an optional\n ``interval`` keyword argument used to mark which interval to use while\n calculating aggregate data between ``start`` and ``end``. This argument\n defaults to ``'days'`` and can accept ``'years'``, ``'months'``,\n ``'weeks'``, ``'days'``, ``'hours'`` or ``'minutes'``.\n It will raise ``InvalidInterval`` otherwise.\n\n This methods returns a list of tuples. The first item in each\n tuple is a ``datetime.datetime`` object for the current inverval. The\n second item is the result of the aggregate operation. For\n example::\n\n [(datetime.datetime(2010, 3, 28, 0, 0), 12), (datetime.datetime(2010, 3, 29, 0, 0), 0), ...]\n\n Formatting of date information is left as an exercise to the user and may\n vary depending on interval used.\n\n``until``\n Provide aggregate information until a given date or time, filtering the\n queryset using ``lte``.\n\n Positional arguments: ``dt`` a ``datetime.date`` or ``datetime.datetime``\n object to be used for filtering the queryset since.\n\n Keyword arguments: ``date_field``, ``aggregate``.\n\n``until_now``\n Aggregate information until now.\n\n Positional arguments: ``dt`` a ``datetime.date`` or ``datetime.datetime``\n object to be used for filtering the queryset since (using ``lte``).\n\n Keyword arguments: ``date_field``, ``aggregate``.\n\n``after``\n Aggregate information after a given date or time, filtering the queryset\n using ``gte``.\n\n Positional arguments: ``dt`` a ``datetime.date`` or ``datetime.datetime``\n object to be used for filtering the queryset since.\n\n Keyword arguments: ``date_field``, ``aggregate``.\n\n``after_now``\n Aggregate information after now.\n\n Positional arguments: ``dt`` a ``datetime.date`` or ``datetime.datetime``\n object to be used for filtering the queryset since (using ``gte``).\n\n Keyword arguments: ``date_field``, ``aggregate``.\n\n``pivot``\n Used by ``since``, ``after``, and ``until_now`` but potentially useful if\n you would like to specify your own operator instead of the defaults.\n\n Positional arguments: ``dt`` a ``datetime.date`` or ``datetime.datetime``\n object to be used for filtering the queryset since (using ``lte``).\n\n Keyword arguments: ``operator``, ``date_field``, ``aggregate``.\n\n Raises ``InvalidOperator`` if the operator provided is not one of ``'lt'``,\n ``'lte'``, ``gt`` or ``gte``.\n\nTesting\n=======\n\nIf you'd like to test ``django-qsstats-magic`` against your local configuration, add\n``qsstats`` to your ``INSTALLED_APPS`` and run ``./manage.py test qsstats``.\nThe test suite assumes that ``django.contrib.auth`` is installed.\n\nFor testing against different python, DB and django versions install tox\n(pip install tox) and run 'tox' from the source checkout::\n\n $ tox\n\nDb user 'qsstats_test' with password 'qsstats_test' and a DB 'qsstats_test'\nshould exist.\n\nDifference from django-qsstats\n==============================\n\n1. Faster time_series method using 1 sql query (currently works for MySQL and\n PostgreSQL, with a fallback to the old method for other DB backends).\n2. Single ``aggregate`` parameter instead of ``aggregate_field`` and\n ``aggregate_class``. Default value is always ``Count('id')`` and can't be\n specified in settings.py. ``QUERYSETSTATS_DEFAULT_OPERATOR`` option is also\n unsupported now.\n3. Support for minute and hour aggregates.\n4. ``start_date`` and ``end_date`` arguments are renamed to ``start`` and\n ``end`` because of 3.\n5. Internals are changed.\n\nI don't know if original author (Matt Croydon) would like my changes so\nI renamed a project for now. If the changes will be merged then\ndjango-qsstats-magic will become obsolete.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/chriskief/django-qsstats-magic-redux", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-qsstats-magic-redux", "package_url": "https://pypi.org/project/django-qsstats-magic-redux/", "platform": "", "project_url": "https://pypi.org/project/django-qsstats-magic-redux/", "project_urls": { "Homepage": "https://bitbucket.org/chriskief/django-qsstats-magic-redux" }, "release_url": "https://pypi.org/project/django-qsstats-magic-redux/0.7.3/", "requires_dist": null, "requires_python": "", "summary": "A django microframework that eases the generation of aggregate data for querysets.", "version": "0.7.3" }, "last_serial": 2653310, "releases": { "0.7.3": [ { "comment_text": "", "digests": { "md5": "41094c34b6d77b53761615ba6f527abc", "sha256": "61d9984b85e087030e333bcf372ca995c35f3db585ff296c6f66a06d03a3f537" }, "downloads": -1, "filename": "django-qsstats-magic-redux-0.7.3.tar.gz", "has_sig": false, "md5_digest": "41094c34b6d77b53761615ba6f527abc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8989, "upload_time": "2017-02-19T18:20:23", "url": "https://files.pythonhosted.org/packages/db/5b/527981adde50aeae34de2c4651497ded2812239d57dfadd54e7ee8a45443/django-qsstats-magic-redux-0.7.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "41094c34b6d77b53761615ba6f527abc", "sha256": "61d9984b85e087030e333bcf372ca995c35f3db585ff296c6f66a06d03a3f537" }, "downloads": -1, "filename": "django-qsstats-magic-redux-0.7.3.tar.gz", "has_sig": false, "md5_digest": "41094c34b6d77b53761615ba6f527abc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8989, "upload_time": "2017-02-19T18:20:23", "url": "https://files.pythonhosted.org/packages/db/5b/527981adde50aeae34de2c4651497ded2812239d57dfadd54e7ee8a45443/django-qsstats-magic-redux-0.7.3.tar.gz" } ] }