Skip to content

Commit 74aef0c

Browse files
committed
Further clarify concepts in Readme
1 parent 2b8f04a commit 74aef0c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# django-range-merge
22

3-
Enables the `range_merge` Aggregate for Django on Postgres. It should only be used with Django projects using the Postgres database. See [Postgres docs on Range Functions](https://www.postgresql.org/docs/14/functions-range.html#RANGE-FUNCTIONS-TABLE).
3+
Enables the `range_merge` Aggregate for Django on Postgres. `range_merge` "Computes the smallest range that includes ... the given ranges".
4+
5+
This package should only be used with Django projects using the Postgres database. See [Postgres docs on Range Functions](https://www.postgresql.org/docs/14/functions-range.html#RANGE-FUNCTIONS-TABLE).
46

57
Note: This app is still a work-in-progress, but currently works. Tests have not yet been implemented.
68

@@ -74,12 +76,22 @@ from django.template.response import TemplateResponse
7476
from .date_utils import get_month_range
7577
7678
def range_of_visitors_this_month(request):
79+
"""
80+
e.g., given the following instance:
81+
{"id" : 1, "name" : "Birthday", "potential_visitors" : "[2, 3)", ...}
82+
{"id" : 2, "name" : "Bake Sale", "potential_visitors" : "[30, 50)", ...}
83+
{"id" : 3, "name" : "Band Camp", "potential_visitors" : "[22, 28)", ...}
84+
{"id" : 4, "name" : "Cooking Show", "potential_visitors" : "[7, 20)", ...}
85+
{"id" : 5, "name" : "Pajama Day", "potential_visitors" : "[15, 30)", ...}
86+
87+
The result would be:
88+
{'output': NumericRange(2, 50, '[)')}
89+
"""
7790
template = "base.html"
7891
7992
context = Event.objects.filter(period__overlaps=get_month_range()).aggregate(
8093
output=Aggregate(F("potential_visitors"), function="range_merge")
8194
)
82-
# example result: {'output': NumericRange(3, 20, '[)')}
8395
8496
return TemplateResponse(request, template, context)
8597
@@ -89,7 +101,7 @@ def overall_dates_of_funded_events(request):
89101
context = Event.objects.filter(is_funded=True).aggregate(
90102
output=Aggregate(F("period"), function="range_merge")
91103
)
92-
# example result: {'output': DateTimeRange("2022-10-01", "2022-12-07", '[)')}
104+
# Example result: {'output': DateTimeRange("2022-10-01", "2022-12-07", '[)')}
93105
94106
return TemplateResponse(request, template, context)
95107

0 commit comments

Comments
 (0)