Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-pg-rrule
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
django-pg-rrule
Commits
aaabb405
Verified
Commit
aaabb405
authored
4 months ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Clean up
parent
376f3d74
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
default
+0
-0
0 additions, 0 deletions
default
django_pg_rrule/managers.py
+8
-34
8 additions, 34 deletions
django_pg_rrule/managers.py
with
8 additions
and
34 deletions
default
0 → 100644
+
0
−
0
View file @
aaabb405
This diff is collapsed.
Click to expand it.
django_pg_rrule/managers.py
+
8
−
34
View file @
aaabb405
...
...
@@ -18,8 +18,8 @@ class RecurrenceManager(CTEManager):
def
with_occurrences
(
self
,
start
:
datetime
|
None
=
None
,
end
:
datetime
|
None
=
None
,
start
:
datetime
,
end
:
datetime
,
start_qs
:
Q
|
None
=
None
,
additional_filter
:
Q
|
None
=
None
,
select_related
:
Sequence
|
None
=
None
,
...
...
@@ -81,7 +81,7 @@ class RecurrenceManager(CTEManager):
function
=
"
get_occurrences
"
,
output_field
=
DateTimeField
(),
),
F
(
"
rdates
"
),
Cast
(
"
rdates
"
,
output_field
=
ArrayField
(
DateTimeField
())
),
function
=
"
ARRAY_CAT
"
,
output_field
=
ArrayField
(
DateTimeField
()),
),
...
...
@@ -100,7 +100,7 @@ class RecurrenceManager(CTEManager):
with_qs
.
only
(
"
id
"
),
name
=
"
qodatetimes
"
,
)
cte_query
=
(
# Join WITH clause with actual data
qs
=
(
# Join WITH clause with actual data
cte
.
join
(
self
.
model
,
id
=
cte
.
col
.
id
)
.
with_cte
(
cte
)
# Annotate WITH clause
...
...
@@ -117,40 +117,14 @@ class RecurrenceManager(CTEManager):
)
)
# single_events_qs = start_qs.filter(
# rrule__isnull=True,
# )
#
# if additional_filter:
# single_events_qs = single_events_qs.filter(additional_filter)
#
# single_events_qs = single_events_qs.filter(
# Q(
# **{
# f"{self.datetime_start_field}__lte": end,
# f"{self.datetime_end_field}__gte": start,
# }
# )
# | Q(
# **{
# f"{self.date_start_field}__lte": end.date(),
# f"{self.date_end_field}__gte": start.date(),
# }
# )
# ).annotate(
# odatetime=F(self.datetime_start_field), odate=F(self.date_start_field)
# )
if
select_related
:
cte_query
=
cte_query
.
select_related
(
*
select_related
)
# single_events_qs = single_events_qs.select_related(*select_related)
qs
=
qs
.
select_related
(
*
select_related
)
if
prefetch_related
:
cte_query
=
cte_query
.
prefetch_related
(
*
prefetch_related
)
# single_events_qs = single_events_qs.prefetch_related(*prefetch_related)
qs
=
qs
.
prefetch_related
(
*
prefetch_related
)
#
qs = (cte_query).union(single_events_qs)
qs
=
cte_query
#
Hacky way to enforce RIGHT OUTER JOIN
# Otherwise, Django always will rewrite the join_type to LEFT OUTER JOIN/INNER JOIN
qs
.
query
.
alias_map
[
"
qodatetimes
"
].
join_type
=
"
RIGHT OUTER JOIN
"
return
qs
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment