{ "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.7", "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.8+\n\nDatabase\n--------\n\nIf timezone support is enabled in Django, the database must have also timezone support installed.\nFor MySQL it might be needed to run:\n\n::\n - mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql\n\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.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PetrDlouhy/django-qsstats-magic", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-qsstats-magic", "package_url": "https://pypi.org/project/django-qsstats-magic/", "platform": "", "project_url": "https://pypi.org/project/django-qsstats-magic/", "project_urls": { "Homepage": "https://github.com/PetrDlouhy/django-qsstats-magic" }, "release_url": "https://pypi.org/project/django-qsstats-magic/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "A django microframework that eases the generation of aggregate data for querysets.", "version": "1.1.0" }, "last_serial": 5572230, "releases": { "0.5.0": [ { "comment_text": "", "digests": { "md5": "b248de2c36af2ed61fee2a6ccc80b72b", "sha256": "b59f8a5296805e910e196dbd1dbf04c398b85d3297a226152559ca6d8b848bdf" }, "downloads": -1, "filename": "django-qsstats-magic-0.5.0.tar.gz", "has_sig": false, "md5_digest": "b248de2c36af2ed61fee2a6ccc80b72b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3576, "upload_time": "2010-07-25T13:19:02", "url": "https://files.pythonhosted.org/packages/4d/50/28bdec5dc08eddfd9da496fcd4d4188537f84a9260064aaaeae4a94fffee/django-qsstats-magic-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "91903b2e909d571d322910698a88ec05", "sha256": "123ff90082a07dadd0a9c574e9362980ed019570985fd3daf70a487dce2d94c4" }, "downloads": -1, "filename": "django-qsstats-magic-0.5.1.tar.gz", "has_sig": false, "md5_digest": "91903b2e909d571d322910698a88ec05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3570, "upload_time": "2010-07-29T20:19:23", "url": "https://files.pythonhosted.org/packages/c0/0b/5b38adf95f9c1f411289b65a0c31f052f064d00158e96c7cffb4121361c9/django-qsstats-magic-0.5.1.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "4912996eeab81850c0ea98bcca9080ee", "sha256": "54b9ae05709b66e37dd93495801e443c87a85fa4b4b2fac0e3c5a4db6039da93" }, "downloads": -1, "filename": "django-qsstats-magic-0.5.2.tar.gz", "has_sig": false, "md5_digest": "4912996eeab81850c0ea98bcca9080ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3588, "upload_time": "2010-10-30T03:13:55", "url": "https://files.pythonhosted.org/packages/b3/81/1fdb735970c54179b570be912ee3fd55e99770308c1d3223d995e4222fec/django-qsstats-magic-0.5.2.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "dae6b06e76270ec03adc174426e0f1ba", "sha256": "fcb18b68dccdc9fb0b4e7bdb96b7bdc82d6d16db4545fe179b006cecec94ff3f" }, "downloads": -1, "filename": "django-qsstats-magic-0.6.tar.gz", "has_sig": false, "md5_digest": "dae6b06e76270ec03adc174426e0f1ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6421, "upload_time": "2011-06-24T22:25:20", "url": "https://files.pythonhosted.org/packages/25/1c/1974216b9ea24d941c5a918115bf7b923d7df59f16f434fc3be163f5ae35/django-qsstats-magic-0.6.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "205190e473710e9d566ce38b5d16385c", "sha256": "8d05488303b450ba644e98ba0a6e86b374a16ddc557be201cb96de3ab8a52800" }, "downloads": -1, "filename": "django-qsstats-magic-0.6.1.tar.gz", "has_sig": false, "md5_digest": "205190e473710e9d566ce38b5d16385c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7830, "upload_time": "2011-06-25T02:52:02", "url": "https://files.pythonhosted.org/packages/40/62/f3beac1f2181acfc47d91c57391ee0ee80e374c8f131de09192f68dd8b47/django-qsstats-magic-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "ad108072df47c9f13401c60f24920f1c", "sha256": "97ac130422f849f21c468e3f52ea234758569d4d4c1df398e614afb458ce9e84" }, "downloads": -1, "filename": "django-qsstats-magic-0.6.2.tar.gz", "has_sig": false, "md5_digest": "ad108072df47c9f13401c60f24920f1c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8044, "upload_time": "2011-09-08T16:03:43", "url": "https://files.pythonhosted.org/packages/ac/c4/adf897eb297558c5fab2927994677c39a9389f6172b0926a29115562297a/django-qsstats-magic-0.6.2.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "bf4b7a7be8fb8623d48fb800129141c4", "sha256": "977a83e96a2cc15804410564d8d487102ad4c93c3bce37c8fb00cea99c388b67" }, "downloads": -1, "filename": "django-qsstats-magic-0.7.tar.gz", "has_sig": false, "md5_digest": "bf4b7a7be8fb8623d48fb800129141c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8721, "upload_time": "2012-05-11T23:31:41", "url": "https://files.pythonhosted.org/packages/45/19/c735b0a07cc65dd8d5b5e63dcf89e3b35a61f98a479aec7c74e450247000/django-qsstats-magic-0.7.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "6bd9d44e00f642d7c6bd06ed7443a0e0", "sha256": "9dbe7b54303950fe54dab6e70518d33585e42b4d9835175eba1b03b4271543f9" }, "downloads": -1, "filename": "django-qsstats-magic-0.7.1.tar.gz", "has_sig": false, "md5_digest": "6bd9d44e00f642d7c6bd06ed7443a0e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8803, "upload_time": "2012-06-07T06:58:02", "url": "https://files.pythonhosted.org/packages/64/db/6b6eb5524da5dfb0b783ece54e89f43cd7bd9c862fcb90f3683f2d179ce0/django-qsstats-magic-0.7.1.tar.gz" } ], "0.7.2": [ { "comment_text": "", "digests": { "md5": "3f7d642d58ae5020f18317ea7b6aa054", "sha256": "eb83731ea890bcbcd7e8edcb634b70f271e0f7aa3eb9b9bf83a7ccc6e69f1565" }, "downloads": -1, "filename": "django-qsstats-magic-0.7.2.tar.gz", "has_sig": false, "md5_digest": "3f7d642d58ae5020f18317ea7b6aa054", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8957, "upload_time": "2013-04-06T10:23:11", "url": "https://files.pythonhosted.org/packages/7d/ea/2e9f552ea8bda30827cab8c9223ba1e275fcd6a314a3a3a2a332547925c7/django-qsstats-magic-0.7.2.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "7d4dcced6571f444f9b4fece1b531fdd", "sha256": "b26cbd320b6303778d95ed333d3f18bc24dacd9d97a27e20973d038b5b565805" }, "downloads": -1, "filename": "django-qsstats-magic-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7d4dcced6571f444f9b4fece1b531fdd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9090, "upload_time": "2017-08-08T11:31:51", "url": "https://files.pythonhosted.org/packages/24/d7/e1059a73ed4958e0f55536e8c9701ceeff8780d6818edacdfe23eccfc213/django-qsstats-magic-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "1f7fe194ada818250bc5f696c09ff742", "sha256": "73268ab20805c9f2e92b8cf54c36adfe03661d90eb5d58da69a5cb4d932c2757" }, "downloads": -1, "filename": "django-qsstats-magic-1.1.0.tar.gz", "has_sig": false, "md5_digest": "1f7fe194ada818250bc5f696c09ff742", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8596, "upload_time": "2019-07-23T12:39:14", "url": "https://files.pythonhosted.org/packages/b1/ba/4578950dd3033f23a334634ea52329a1b1287c87b9f02943181a546bb2ea/django-qsstats-magic-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1f7fe194ada818250bc5f696c09ff742", "sha256": "73268ab20805c9f2e92b8cf54c36adfe03661d90eb5d58da69a5cb4d932c2757" }, "downloads": -1, "filename": "django-qsstats-magic-1.1.0.tar.gz", "has_sig": false, "md5_digest": "1f7fe194ada818250bc5f696c09ff742", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8596, "upload_time": "2019-07-23T12:39:14", "url": "https://files.pythonhosted.org/packages/b1/ba/4578950dd3033f23a334634ea52329a1b1287c87b9f02943181a546bb2ea/django-qsstats-magic-1.1.0.tar.gz" } ] }