{ "info": { "author": "Rodolphe Qui\u00e9deville", "author_email": "rodolphe@quiedeville.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.7" ], "description": "django-aggtrigg\n===============\n\nAutomatic trigger generator for Django\n\n.. image:: https://img.shields.io/pypi/v/djorm-pgarray.svg?style=flat\n :target: https://pypi.python.org/pypi/django-aggtrigg\n\n.. image:: https://img.shields.io/pypi/dm/djorm-pgarray.svg?style=flat\n :target: https://pypi.python.org/pypi/django-aggtrigg\n\n.. image:: https://travis-ci.org/novafloss/django-aggtrigg.svg\n :target: https://travis-ci.org/novafloss/django-aggtrigg\n\nCreate triggers to do some aggregate and permit to count objects from\ndatabase without using COUNT() aggregat.\nDetailed documentation is in the \"docs\" directory.\n\nQuick start\n-----------\n\n1. Add \"django_aggtrigg\" to your INSTALLED_APPS setting like this::\n\n INSTALLED_APPS = (\n ...\n 'django_aggtrigg',\n )\n\n2. Import fields in your models::\n\n from django_aggtrigg.models import IntegerTriggerField\n from django_aggtrigg.models import FloatTriggerField\n\n3. Configure your fields as is::\n\n class Apple(models.Model):\n indice = IntegerTriggerField(default=0)\n indice.aggregate_trigger=['count','min']\n\n mark = FloatTriggerField(default=0)\n mark.aggregate_trigger=['min']\n\nBy default only the `count` aggregat will be created.\n\n4. Use the new manager on you Model\n\n objects = AggTriggManager()\n\n\nManage triggers and related objects\n-----------------------------------\n\nTo create the triggers in the database do::\n\n python manage.py aggtrigg_create\n\nDropping triggers is easy as doing::\n\n python manage.py aggtrigg_drop | psql -d DATABASE NAME\n\nFor safety reason the drop command just ouptput on stdout the SQL statements.\n\nTo initialize the aggregeate table, you can fill it by hand or do::\n\n python manage.py aggtrigg_initialize\n\nHowto use the new aggregat\n--------------------------\n\nInstead of doing a COUNT as the traditionnal way::\n\n Apple.objects.filter(indice=42).count()\n\nyou will do::\n\n Apple.objects.optimized_count(indice=42)\n\nThis is may be less easy, but so much more efficient when you\nmanipulate billions or tuples in your relations.\n\nWhat inside\n-----------\n\nThe class **apple** was create in the app called **foo** so the\ndefault name of the table that contains data will be **foo_apple**, we\nuse the tablename from the Model so if it's changed in **Meta** will\nstill be compliant.\n\nA new table **foo_apple__indice_agg** is created in the same database\nas **foo_apple**, it will contain the aggregat::\n\n foo=# \\d foo_apple__indice_agg\n Table \"public.foo_apple__indice_agg\"\n Column | Type | Modifiers\n -----------+---------+-----------\n indice | integer |\n agg_count | integer |\n agg_min | integer |\n Indexes:\n \"foo_apple__indice_agg_indice_idx\" btree (indice)\n\nAggregate on related table\n--------------------------\n\nIf you need to maintain count on related objects, for example the\ncomment count per Article, you can use ForeignKeyTriggerField::\n\n from django_aggtrigg.models import ForeignKeyTriggerField\n\nTrade the ForeignKey on ArticleComment for a ForeignKeyTriggerField::\n\n class ArticleComment(models.Model):\n ...\n article = ForeignKeyTriggerField(Article)\n ...\n\nAdd simple count::\n\n article.aggregate_trigger = [\"count\"]\n\nOr complex one with some filters::\n\n article.aggregate_trigger = [{'count': [\n {'private': [ {\n \"field\": \"is_private\",\n \"value\": False}\n ]\n }\n ]\n }]\n\nCreate your triggers::\n\n python manage.py aggtrigg_create\n\nInitialize your triggers::\n\n python manage.py aggtrigg_initialize\n\n\nTo use those triggers easily, you can use AggCount manager::\n\n from django_aggtrigg.models import AggCount\n\n ArticleManager = Manager.include(AggCount)\n\nAggCount give you a new method on your model: ``get_count``. You can\nuse it juste like a traditional queryset method. ex::\n\n Article.objects.filter(..).get_count().values(\"articlecomment_count_private\")\n [{'ticketcomment_count_private': 4},\n {'ticketcomment_count_private': 2},..]\n\n Article.objects.filter(..).get_count().first().__dict__\n {'id': 24,\n ...\n 'ticketcomment_count_private': 3\n ...}\n\nThe only thing you cannot do with get_count is filtering on the\naggregates. ex::\n\n Article.objects.get_count().filter(articlecomment_count_private__gte=3)\n # THIS DOES NOT WORK !!!\n\nBecause the aggregates are not on the table you working on, Django\ndoes not really know anything about this table. THis is the reason why\nyou do not have to bother with migrations.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://django-aggtrigg.readthedocs.org/", "keywords": "aggregat trigger count min maxdatabase index postgresql django", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-aggtrigg", "package_url": "https://pypi.org/project/django-aggtrigg/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-aggtrigg/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://django-aggtrigg.readthedocs.org/" }, "release_url": "https://pypi.org/project/django-aggtrigg/1.1.0/", "requires_dist": null, "requires_python": null, "summary": "Django complementary index definition and management.", "version": "1.1.0" }, "last_serial": 1648326, "releases": { "0.6.0": [ { "comment_text": "", "digests": { "md5": "d9b224dbc31148788a26bcb9d1a72a05", "sha256": "35a06cc6bec877d62b9aa2c7a091845ccbb55c9edf10486565f4d4ad4a5f35ed" }, "downloads": -1, "filename": "django-aggtrigg-0.6.0.tar.gz", "has_sig": false, "md5_digest": "d9b224dbc31148788a26bcb9d1a72a05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10588, "upload_time": "2014-12-12T11:37:48", "url": "https://files.pythonhosted.org/packages/30/d7/6343d9cfb53bcd1a2e067bbd10adf18473576059fd74ac7de7133140841d/django-aggtrigg-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "7582a530f491285fe16f939276447b2b", "sha256": "cf8d40c4f6af7e77096fc7daef13f1fc4592eb033a40fd75d4f634409fd2864b" }, "downloads": -1, "filename": "django-aggtrigg-0.6.1.tar.gz", "has_sig": false, "md5_digest": "7582a530f491285fe16f939276447b2b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10571, "upload_time": "2014-12-12T11:47:44", "url": "https://files.pythonhosted.org/packages/16/e7/db8ff1b9eccc76b991a6a78500b6cc867c4ce64ff5ddbbca32c4d8656e0b/django-aggtrigg-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "1704460ebc7509752d1e371e7fbdfdc6", "sha256": "500d1e8e455c2359cc9d21b9823235007d4da69e0a893709da9c8daf331769ff" }, "downloads": -1, "filename": "django-aggtrigg-0.6.2.tar.gz", "has_sig": false, "md5_digest": "1704460ebc7509752d1e371e7fbdfdc6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10565, "upload_time": "2014-12-12T18:38:19", "url": "https://files.pythonhosted.org/packages/2c/9a/cd9e18a8921ef9b00535c16f7dfd1d8b019dff681328a4a4964f67c28f73/django-aggtrigg-0.6.2.tar.gz" } ], "0.6.3": [ { "comment_text": "", "digests": { "md5": "beaf065fc675538a2b10e733875f4499", "sha256": "1a9572d9a66df8eca883cb25f9482feb3c70cc2db449328f42987b7b513fee55" }, "downloads": -1, "filename": "django-aggtrigg-0.6.3.tar.gz", "has_sig": false, "md5_digest": "beaf065fc675538a2b10e733875f4499", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10552, "upload_time": "2014-12-12T20:16:36", "url": "https://files.pythonhosted.org/packages/d1/92/43ff0cff1b7faa8605bf8b58f14ce81301af5153dbdb0cc9ae8a38c236f6/django-aggtrigg-0.6.3.tar.gz" } ], "0.6.4": [ { "comment_text": "", "digests": { "md5": "be8187c7769e8908351bb947fccd4a18", "sha256": "c3fa97e1b8d860caaac0c364eb60dd2b53c7c38cf9a89a966fd877a382f110d1" }, "downloads": -1, "filename": "django-aggtrigg-0.6.4.tar.gz", "has_sig": false, "md5_digest": "be8187c7769e8908351bb947fccd4a18", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16038, "upload_time": "2014-12-12T20:21:21", "url": "https://files.pythonhosted.org/packages/c0/10/c734ed0d3b409563cbbd07ac2381dc84ca6af854ffa519e145a6cdc71227/django-aggtrigg-0.6.4.tar.gz" } ], "0.6.5": [ { "comment_text": "", "digests": { "md5": "7f708a4e6b453241d7f8974d1667f6db", "sha256": "d9b3589b504d30386ecf2723ae69363e17c1f0d065ed526abebd3f644f44ecdf" }, "downloads": -1, "filename": "django-aggtrigg-0.6.5.tar.gz", "has_sig": false, "md5_digest": "7f708a4e6b453241d7f8974d1667f6db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16064, "upload_time": "2014-12-21T18:14:34", "url": "https://files.pythonhosted.org/packages/cf/01/1e3028177addc0a6706faf0d3d77131032d5a21d28979ce7208c8f52de3a/django-aggtrigg-0.6.5.tar.gz" } ], "0.6.6": [ { "comment_text": "", "digests": { "md5": "0df485ff4554febd5e40e7e16a2ff4a5", "sha256": "e858c5535daf951bb688da4b2b9ec726da5dbd21f13eeb1d28762cb321e006a4" }, "downloads": -1, "filename": "django-aggtrigg-0.6.6.tar.gz", "has_sig": false, "md5_digest": "0df485ff4554febd5e40e7e16a2ff4a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16457, "upload_time": "2015-03-13T13:23:15", "url": "https://files.pythonhosted.org/packages/72/c1/c5d411f7cae4edccf2f852550dec7c6cec168d99fa64b1374f6b40bb8592/django-aggtrigg-0.6.6.tar.gz" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "48fe999a93749ebb98f227c34cebae67", "sha256": "b331f4061776479764620737f6188115f10da73a5351bd7ca55a73991d10e30f" }, "downloads": -1, "filename": "django-aggtrigg-0.7.0.tar.gz", "has_sig": false, "md5_digest": "48fe999a93749ebb98f227c34cebae67", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20488, "upload_time": "2015-04-09T09:06:36", "url": "https://files.pythonhosted.org/packages/74/d9/949efd0191dc45e6eb36ca96842a4a06e77e16d992cb7cedade76502f960/django-aggtrigg-0.7.0.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "0821b45921b4e08c9ace8b6d5ef2315a", "sha256": "c0a4d247bf72a94be2a797f0e26d9ec9c1eb03c8dbc09052c3892600681b7b00" }, "downloads": -1, "filename": "django-aggtrigg-0.7.1.tar.gz", "has_sig": false, "md5_digest": "0821b45921b4e08c9ace8b6d5ef2315a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20626, "upload_time": "2015-04-13T11:49:36", "url": "https://files.pythonhosted.org/packages/2e/cd/ffe006e69b53a5d2c358b7687ae50168481038974600d04b5c24fa2cf1b3/django-aggtrigg-0.7.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "5204a8b5fd46bd23714e0c0ecb9a7c5a", "sha256": "b2293752167467cdd4e9726595d3206b2fb29482115fac2f6a412a02f7fcc70e" }, "downloads": -1, "filename": "django-aggtrigg-1.0.0.tar.gz", "has_sig": false, "md5_digest": "5204a8b5fd46bd23714e0c0ecb9a7c5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22071, "upload_time": "2015-05-28T13:06:17", "url": "https://files.pythonhosted.org/packages/72/58/54190f90bf884a4dc43b4afef6df5c0daeb9b75eb4000bc931ae4840e79d/django-aggtrigg-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "69ff44008532617765d402fcc541c536", "sha256": "c7b1a63d0a3e80ae2264d8d8b1d48c9a40db6991c1ccf992c635401d645b37f9" }, "downloads": -1, "filename": "django-aggtrigg-1.1.0.tar.gz", "has_sig": false, "md5_digest": "69ff44008532617765d402fcc541c536", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21987, "upload_time": "2015-07-24T16:25:32", "url": "https://files.pythonhosted.org/packages/9d/5d/ef96bfed3452747e7269399ffb14ffb0954a3005699574fbbd356b709171/django-aggtrigg-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "69ff44008532617765d402fcc541c536", "sha256": "c7b1a63d0a3e80ae2264d8d8b1d48c9a40db6991c1ccf992c635401d645b37f9" }, "downloads": -1, "filename": "django-aggtrigg-1.1.0.tar.gz", "has_sig": false, "md5_digest": "69ff44008532617765d402fcc541c536", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21987, "upload_time": "2015-07-24T16:25:32", "url": "https://files.pythonhosted.org/packages/9d/5d/ef96bfed3452747e7269399ffb14ffb0954a3005699574fbbd356b709171/django-aggtrigg-1.1.0.tar.gz" } ] }