Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Video AG Infrastruktur
website
Commits
0c1c9c49
Commit
0c1c9c49
authored
1 year ago
by
Simon Künzel
Browse files
Options
Downloads
Patches
Plain Diff
Request insertion auto increment value explicitly
parent
b448ee30
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
chapters.py
+2
-1
2 additions, 1 deletion
chapters.py
db.py
+7
-5
7 additions, 5 deletions
db.py
edit.py
+3
-1
3 additions, 1 deletion
edit.py
jobmanagement.py
+2
-1
2 additions, 1 deletion
jobmanagement.py
sorter.py
+2
-1
2 additions, 1 deletion
sorter.py
with
16 additions
and
9 deletions
chapters.py
+
2
−
1
View file @
0c1c9c49
...
...
@@ -40,7 +40,8 @@ def suggest_chapter(lectureid):
course
=
query
(
'
SELECT * FROM courses WHERE id = ?
'
,
lecture
[
'
course_id
'
])[
0
]
id
=
modify
(
'
INSERT INTO chapters (lecture_id, time, text, time_created, time_updated, created_by, submitted_by) VALUES (?, ?, ?, ?, ?, ?, ?)
'
,
lectureid
,
chapter_start
,
text
,
datetime
.
now
(),
datetime
.
now
(),
session
.
get
(
'
user
'
,
{
'
dbid
'
:
None
})[
'
dbid
'
],
submitter
lectureid
,
chapter_start
,
text
,
datetime
.
now
(),
datetime
.
now
(),
session
.
get
(
'
user
'
,
{
'
dbid
'
:
None
})[
'
dbid
'
],
submitter
,
get_id
=
True
)
chapter
=
query
(
'
SELECT * FROM chapters WHERE id = ?
'
,
id
)[
0
]
if
not
ismod
():
...
...
This diff is collapsed.
Click to expand it.
db.py
+
7
−
5
View file @
0c1c9c49
...
...
@@ -100,8 +100,8 @@ def query(operation, *params, delim="sep", nlfix=True):
try
:
cur
=
get_dbcursor
()
cur
.
execute
(
operation
,
params
)
except
mysql
.
connector
.
errors
.
InternalError
as
e
:
if
e
.
msg
==
'
Deadlock found when trying to get lock; try restarting transaction
'
:
except
Exception
as
e
:
if
str
(
e
)
==
'
Deadlock found when trying to get lock; try restarting transaction
'
:
tries
+=
1
retry
=
True
else
:
...
...
@@ -109,8 +109,8 @@ def query(operation, *params, delim="sep", nlfix=True):
rows
=
[]
try
:
rows
=
cur
.
fetchall
()
except
mysql
.
connector
.
errors
.
InterfaceError
as
e
:
if
e
.
msg
==
'
No result set to fetch from.
'
:
except
Exception
as
e
:
if
str
(
e
)
==
'
No result set to fetch from.
'
or
str
(
e
)
==
"
the last operation didn
'
t produce a result
"
:
# no problem, we were just at the end of the result set
pass
else
:
...
...
@@ -129,10 +129,12 @@ def query(operation, *params, delim="sep", nlfix=True):
ptr
[
name
]
=
col
return
res
def
modify
(
operation
,
*
params
):
def
modify
(
operation
,
*
params
,
get_id
=
False
):
operation
,
params
=
fix_query
(
operation
,
params
)
cur
=
get_dbcursor
()
cur
.
execute
(
operation
,
params
)
if
not
get_id
:
return
None
return
cur
.
lastrowid
@app.teardown_request
...
...
This diff is collapsed.
Click to expand it.
edit.py
+
3
−
1
View file @
0c1c9c49
...
...
@@ -227,8 +227,10 @@ def create(table):
assert
column
not
in
defaults
columns
.
append
(
'"'
+
column
+
'"'
)
values
.
append
(
val
)
assert
editable_tables
[
table
][
'
idcolumn
'
]
==
'
id
'
id
=
modify
(
'
INSERT INTO %s (%s) VALUES (%s)
'
%
(
editable_tables
[
table
][
'
table
'
],
'
,
'
.
join
(
columns
),
'
,
'
.
join
([
'
?
'
]
*
len
(
values
))),
*
values
)
'
,
'
.
join
(
columns
),
'
,
'
.
join
([
'
?
'
]
*
len
(
values
))),
*
values
,
get_id
=
True
)
if
table
==
'
courses
'
:
set_responsible
(
id
,
session
[
'
user
'
][
'
dbid
'
],
1
)
if
'
ref
'
in
request
.
values
:
...
...
This diff is collapsed.
Click to expand it.
jobmanagement.py
+
2
−
1
View file @
0c1c9c49
...
...
@@ -50,7 +50,8 @@ def schedule_job(jobtype, data=None, priority=0, queue="default"):
if
not
data
:
data
=
{}
return
modify
(
'
INSERT INTO jobs (type, priority, queue, data, time_created) VALUES (?, ?, ?, ?, ?)
'
,
jobtype
,
priority
,
queue
,
json
.
dumps
(
data
,
default
=
date_json_handler
),
datetime
.
now
())
jobtype
,
priority
,
queue
,
json
.
dumps
(
data
,
default
=
date_json_handler
),
datetime
.
now
(),
get_id
=
True
)
def
cancel_job
(
job_id
):
query
(
'
UPDATE jobs SET state =
\'
deleted
\'
WHERE id = ? AND state =
\'
ready
\'
'
,
job_id
)
...
...
This diff is collapsed.
Click to expand it.
sorter.py
+
2
−
1
View file @
0c1c9c49
...
...
@@ -61,7 +61,8 @@ def insert_video(lectureid, dbfilepath, fileformatid, hash="", filesize=-1, dura
(lecture_id, visible, path, video_format, title, comment, internal, file_modified, time_created, time_updated, created_by, hash, file_size, duration, source)
VALUES
(?, ?, ?, ?,
''
,
''
,
''
, ?, ?, ?, ?, ?, ?, ?, ?)
'''
,
lectureid
,
visible
,
dbfilepath
,
fileformatid
,
datetime
.
now
(),
datetime
.
now
(),
datetime
.
now
(),
-
1
,
hash
,
filesize
,
duration
,
sourceid
)
lectureid
,
visible
,
dbfilepath
,
fileformatid
,
datetime
.
now
(),
datetime
.
now
(),
datetime
.
now
(),
-
1
,
hash
,
filesize
,
duration
,
sourceid
,
get_id
=
True
)
if
not
sourceid
:
query
(
'
INSERT INTO sortlog (lecture_id,video_id,path,
"
when
"
) VALUES (?,?,?,?)
'
,
lectureid
,
video_id
,
dbfilepath
,
datetime
.
now
())
schedule_job
(
'
probe
'
,
{
'
path
'
:
dbfilepath
,
'
lecture_id
'
:
lectureid
,
'
video_id
'
:
video_id
,
'
import-chapters
'
:
True
})
...
...
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