{ "info": { "author": "Anthony Almarza", "author_email": "", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "TimeSeries\n==========\n\n|Build Status|\n\n|Coverage Status|\n\n``timeseries`` is a set django application tools designed to facilitate\nthe collation and maintenance of timeseries data.\n\nRequirements\n------------\n\nDjango versions 1.8+ are supported for projects running on PostgreSQL.\n\nInstallation\n------------\n\n``pip install django-timeseries``\n\nUsage\n-----\n\n.. code:: python\n\n from datetime import timedelta\n from django.db import models\n from timeseries.utils import TimeSeriesModel, TimeSeriesManager\n\n\n class Ad(models.Model):\n\n objects = TimeSeriesManager()\n\n\n class RawAdData(TimeSeriesModel):\n\n TIMESERIES_INTERVAL = timedelta(days=1) # update daily N.B integers in seconds also work\n\n NOT_AVAILABLE = -1\n\n ad = models.ForeignKey(Ad, related_name='rawdata')\n\n views = models.BigIntegerField(default=NOT_AVAILABLE)\n clicks = models.BigIntegerField(default=NOT_AVAILABLE)\n\n\n class MonthlyAdReport(TimeSeriesModel):\n\n TIMESERIES_INTERVAL = timedelta(days=28)\n\n ad = models.ForeignKey(Ad, related_name='monthlyreports')\n\n avg_view_growth = models.FloatField()\n avg_click_growth = models.FloatField()\n\n\n def ad_data_collector(queryset):\n \"\"\"\n should return an iterable that yields dictionaries of data\n needed to successfully create a RawAdData instance\n \"\"\"\n return ...\n\n\n def report_data_collector(queryset):\n \"\"\"\n should return an iterable that yields dictionaries of data\n needed to successfully create a MonthlyAdReport instance\n \"\"\"\n return ...\n\n\n # in a shell\n >>> Ad.objects.update_timeseries('rawdata', ad_data_collector)\n # this return the results of a bulk_create call from the RawAdData manager\n # for ads that hadn't been updated in the last day\n\n >>> Ad.objects.update_timeseries('monthlyreports', report_data_collector)\n # this return the results of a bulk_create call from the MonthlyAdReport\n # manager for ads that hadn't had a report generated in the last 28 days\n\n >>> ad = Ad.objects.prefetch_latest('rawdata', 'monthlyreports').first()\n >>> print ad.latest_rawaddata, ad.latest_monthlyreports\n\nTimeSeries QuerySet Methods\n---------------------------\n\n``timeseries.utils.TimeSeriesQuerySet``\n\nAdds 4 main methods to the Django QuerySet API that can be used to\nupdate and maintain timeseries data. These methods include:\n\n- prefetch\\_latest\n- filter\\_outdated\n- last\\_updated\n- update\\_timeseries\n\n``update_timeseries``\n~~~~~~~~~~~~~~~~~~~~~\n\nInputs: ``related_name``, ``collector``, optional ``force``\n\nReturns: list of instatiated related models.\n\nUpdates the queryset's related model table (as given by related\\_name)\nusing a provider \"collector\" callable.\n\n\"collector\" must take a queryset of the referenced models as its only\nargument. It must also return an iterable of dictionaries that can be\nused to construct and save instances of the related model.\n\nN.B. Only instances that have outdated data will be updated unless\nexplicitly forced using the \"force\" keyword argument.\n\n``filter_outdated``\n~~~~~~~~~~~~~~~~~~~\n\nInputs: ``*related_names``\n\nReturns: queryset\n\nReturns a queryset that will yield the model instances that have\n\"outdated\" data associated to reverse related model as given by the\nspecified related\\_name.\n\n``last_updated``\n~~~~~~~~~~~~~~~~\n\nInputs: ``*related_names``\n\nReturns: queryset\n\nAnnotates the created timestamp of the latest related instance as given\nby the reverse relation's related\\_name.\n\nUsage:\n\n.. code:: python\n\n ad = Ad.objects.last_updated('rawdata').first()\n # assuming there's data related to ad\n print ad.rawdata_last_updated\n # this will print the timestamp of when the associated data was\n # last updated\n\n``prefetch_latest``\n~~~~~~~~~~~~~~~~~~~\n\nInputs: ``*related_names``\n\nReturns: queryset\n\nExposes the latest associated reverse relation.\n\nUsage:\n\n.. code:: python\n\n ad = Ad.objects.prefetch_latest('rawdata', 'monthlyreports').first()\n print ad.latest_rawaddata, ad.latest_monthlyreports\n # this will print the reprs of the latest associated data\n # instances\n\nOther Utilities\n---------------\n\n``LatestQ``\n~~~~~~~~~~~\n\n``timeseries.utils``\n\nInputs: ``related_name``, ``**kwargs``\n\nReturns: django.db.models.Q instance\n\nConstructs a django.db.models.Q instance that allows queries to be\nexecuted against the latest associated reverse relation.\n\nN.B. this method is designed to be used in conjunction with\ntimeseries.utils.TimeSeriesQuerySet.last\\_updated.\n\nUsage:\n\n.. code:: python\n\n Ad.objects.last_updated('rawdata').filter(\n LatestQ('rawdata', views__gt=1000)\n )\n\n.. |Build Status| image:: https://travis-ci.org/anthonyalmarza/timeseries.svg?branch=master\n :target: https://travis-ci.org/anthonyalmarza/timeseries\n.. |Coverage Status| image:: https://coveralls.io/repos/github/anthonyalmarza/timeseries/badge.svg?branch=master\n :target: https://coveralls.io/github/anthonyalmarza/timeseries?branch=master\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/anthonyalmarza/timeseries", "keywords": "timeseries,django,data,latest", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-timeseries", "package_url": "https://pypi.org/project/django-timeseries/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-timeseries/", "project_urls": { "Homepage": "https://github.com/anthonyalmarza/timeseries" }, "release_url": "https://pypi.org/project/django-timeseries/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "`timeseries` is a set of django application tools designed to facilitate the collation and maintenance of timeseries data.", "version": "1.0.2" }, "last_serial": 2291614, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "bbc3f16da9a3f4f63d846015dbbaf4de", "sha256": "2b7f94f89324a2c51a0509ed30014b9552bb9688fc5aebb577f94852925ac8e6" }, "downloads": -1, "filename": "django-timeseries-0.0.0.tar.gz", "has_sig": false, "md5_digest": "bbc3f16da9a3f4f63d846015dbbaf4de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3464, "upload_time": "2016-04-22T18:19:36", "url": "https://files.pythonhosted.org/packages/f7/0a/7ab8c09b6b53dc0de002112345f7ba2fdcd02388c198fb564ac024ca2b17/django-timeseries-0.0.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "b3071652da096a6eb417dfff04428119", "sha256": "e26ecbf938eb2b323a726179724152aaf00d36fd93e20571dec1d984d3da9a98" }, "downloads": -1, "filename": "django-timeseries-1.0.0.tar.gz", "has_sig": false, "md5_digest": "b3071652da096a6eb417dfff04428119", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5729, "upload_time": "2016-04-23T17:53:41", "url": "https://files.pythonhosted.org/packages/ee/cb/a22caf1c50cd679835f63183902fa437d1986e65bf167f574022db94b5c3/django-timeseries-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "6b0ccb3f4acc8276cb9be6d1b1f3b1fc", "sha256": "96b48e3c1b6064e1f93b803a9f58d6521818ab8934abc297da00a9d869cd077c" }, "downloads": -1, "filename": "django-timeseries-1.0.1.tar.gz", "has_sig": false, "md5_digest": "6b0ccb3f4acc8276cb9be6d1b1f3b1fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5902, "upload_time": "2016-04-24T12:58:33", "url": "https://files.pythonhosted.org/packages/66/83/0272a0ddd25bb4b03f5bdceb4072edcaeaa118159179add4816c2a4f873a/django-timeseries-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "3a35cbd240e605d8591fd03fa402b9c7", "sha256": "d0d9b84b65e1198d6d8b521fc634868f5b77a498716ff9ac22baff82095a3517" }, "downloads": -1, "filename": "django-timeseries-1.0.2.tar.gz", "has_sig": false, "md5_digest": "3a35cbd240e605d8591fd03fa402b9c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5932, "upload_time": "2016-08-19T20:11:45", "url": "https://files.pythonhosted.org/packages/86/be/f2b94d994f8f1074dafce509e0b19970cc3d1b4953e7ce13b98d6022852f/django-timeseries-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3a35cbd240e605d8591fd03fa402b9c7", "sha256": "d0d9b84b65e1198d6d8b521fc634868f5b77a498716ff9ac22baff82095a3517" }, "downloads": -1, "filename": "django-timeseries-1.0.2.tar.gz", "has_sig": false, "md5_digest": "3a35cbd240e605d8591fd03fa402b9c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5932, "upload_time": "2016-08-19T20:11:45", "url": "https://files.pythonhosted.org/packages/86/be/f2b94d994f8f1074dafce509e0b19970cc3d1b4953e7ce13b98d6022852f/django-timeseries-1.0.2.tar.gz" } ] }