Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
6b9a973b
Verified
Commit
6b9a973b
authored
11 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
fix: don’t use bulk_create and don’t ignore conflicts
parent
383f2db8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7797
passed
11 months ago
Stage: build
Stage: test
Stage: deploy
Stage: release
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/management/commands/addtimeslots.py
+13
-2
13 additions, 2 deletions
program/management/commands/addtimeslots.py
with
13 additions
and
2 deletions
program/management/commands/addtimeslots.py
+
13
−
2
View file @
6b9a973b
...
@@ -3,6 +3,7 @@ from datetime import datetime
...
@@ -3,6 +3,7 @@ from datetime import datetime
from
dateutil.rrule
import
rrule
from
dateutil.rrule
import
rrule
from
django.core.management
import
BaseCommand
from
django.core.management
import
BaseCommand
from
django.db
import
IntegrityError
from
django.utils.timezone
import
make_aware
from
django.utils.timezone
import
make_aware
from
program.models
import
RRule
,
Schedule
,
TimeSlot
from
program.models
import
RRule
,
Schedule
,
TimeSlot
...
@@ -34,6 +35,8 @@ class Command(BaseCommand):
...
@@ -34,6 +35,8 @@ class Command(BaseCommand):
for
schedule
in
(
for
schedule
in
(
Schedule
.
objects
.
exclude
(
rrule
=
once
).
filter
(
last_date
=
None
).
order_by
(
"
show__name
"
)
Schedule
.
objects
.
exclude
(
rrule
=
once
).
filter
(
last_date
=
None
).
order_by
(
"
show__name
"
)
):
):
added
=
0
skipped
=
0
last_timeslot
=
schedule
.
timeslots
.
last
()
last_timeslot
=
schedule
.
timeslots
.
last
()
# add timeslots to the schedules with no timeslot this year
# add timeslots to the schedules with no timeslot this year
...
@@ -65,8 +68,16 @@ class Command(BaseCommand):
...
@@ -65,8 +68,16 @@ class Command(BaseCommand):
)
)
)
)
else
:
else
:
TimeSlot
.
objects
.
bulk_create
(
timeslots
,
ignore_conflicts
=
True
)
for
timeslot
in
timeslots
:
try
:
timeslot
.
save
()
except
IntegrityError
:
skipped
+=
1
else
:
added
+=
1
self
.
stdout
.
write
(
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
f
"
added
{
str
(
len
(
timeslots
))
}
timeslots to
{
schedule
}
"
)
self
.
style
.
SUCCESS
(
f
"
added
{
str
(
added
)
}
timeslots to
{
schedule
}
, skipped
{
str
(
skipped
)
}
"
)
)
)
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