Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ru-bot-telegram
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CAAD
ru-bot-telegram
Commits
99bc36df
Commit
99bc36df
authored
Feb 9, 2022
by
fmk17
Browse files
Options
Downloads
Patches
Plain Diff
Don't insert duplicate schedule
parent
df78f4a1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
database.py
+20
-7
20 additions, 7 deletions
database.py
with
20 additions
and
7 deletions
database.py
+
20
−
7
View file @
99bc36df
...
@@ -36,6 +36,19 @@ def get_schedules_for_user(user_id):
...
@@ -36,6 +36,19 @@ def get_schedules_for_user(user_id):
)
for
row
in
rows
]
)
for
row
in
rows
]
def
insert_schedule
(
schedule
):
def
insert_schedule
(
schedule
):
cur
=
connection
.
execute
(
'''
SELECT created_at
FROM schedule
WHERE time = ? and day_week = ? and location = ? and meal = ? and user_id = ?
'''
,
(
schedule
.
time
,
schedule
.
day_week
,
schedule
.
location
.
name
,
schedule
.
meal
.
name
,
schedule
.
user_id
))
row
=
cur
.
fetchone
()
if
not
row
:
connection
.
execute
(
'''
connection
.
execute
(
'''
INSERT INTO schedule
INSERT INTO schedule
(time, day_week, location, meal, user_id, created_at)
(time, day_week, location, meal, user_id, created_at)
...
...
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