Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hiro
GetTor
Commits
06006013
Commit
06006013
authored
May 23, 2019
by
Hiro
🏄
Browse files
Update stats db operations
parent
9723be42
Changes
1
Hide whitespace changes
Inline
Side-by-side
gettor/utils/db.py
View file @
06006013
...
...
@@ -88,12 +88,18 @@ class SQLite3(object):
Update statistics to the database
"""
now_str
=
datetime
.
now
().
strftime
(
"%Y%m%d"
)
query
=
"INSERT INTO stats(num_requests, platform, language, command, "
\
"service, date) VALUES (1, ?, ?, ?, ?, ?) ON CONFLICT(platform, "
\
"language, command, service, date) DO UPDATE SET num_requests=num_requests+1"
# This query isn't the nicest until upsert isn't supported
query
=
"BEGIN;"
\
"INSERT OR IGNORE INTO stats(num_requests, platform, language, "
\
"command, service, date) VALUES (0, ?, ?, ?, ?, ?); "
\
"UPDATE stats SET num_requests = num_requests + 1 WHERE platform=? "
\
"AND language=? AND command=? AND service=? AND date=?; "
\
"COMMIT;"
return
self
.
dbpool
.
runQuery
(
query
,
(
platform
,
language
,
command
,
service
,
now_str
)
query
,
(
platform
,
language
,
command
,
service
,
now_str
,
platform
,
language
,
command
,
service
,
now_str
)
).
addCallback
(
self
.
query_callback
).
addErrback
(
self
.
query_errback
)
def
get_links
(
self
,
platform
,
language
,
status
):
...
...
Hiro
🏄
@hiro
mentioned in commit
caa003c1
·
Sep 06, 2019
mentioned in commit
caa003c1
mentioned in commit caa003c1e723aa2d7afad44889d1e6c6bafc34ac
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment