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
9723be42
Commit
9723be42
authored
May 23, 2019
by
Hiro
🏄
Browse files
Update create_db script and stats db operations
parent
adceca12
Changes
3
Hide whitespace changes
Inline
Side-by-side
gettor/utils/db.py
View file @
9723be42
...
...
@@ -88,12 +88,12 @@ class SQLite3(object):
Update statistics to the database
"""
now_str
=
datetime
.
now
().
strftime
(
"%Y%m%d"
)
query
=
"
REPLACE
INTO stats(num_requests, platform, language, "
\
"command,
service, date) VALUES
(COALESCE((SELECT num_requests FROM stats
"
\
"
WHERE platform=? AND language=? AND date=?)+1, 0), ?, ?, ?, ?, ?) "
\
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"
return
self
.
dbpool
.
runQuery
(
query
,
(
platform
,
language
,
now_str
,
platform
,
language
,
command
,
service
,
now_str
)
query
,
(
platform
,
language
,
command
,
service
,
now_str
)
).
addCallback
(
self
.
query_callback
).
addErrback
(
self
.
query_errback
)
def
get_links
(
self
,
platform
,
language
,
status
):
...
...
scripts/create_db
View file @
9723be42
...
...
@@ -91,7 +91,8 @@ def main():
)
c
.
execute
(
"CREATE TABLE stats(num_requests NUMBER, platform TEXT,"
" language TEXT, command TEXT, service TEXT, date TEXT)"
" language TEXT, command TEXT, service TEXT, date,"
" PRIMARY KEY (platform, language, command, service, date))"
)
print
(
"Database {} created."
.
format
(
abs_filename
))
elif
args
.
clear
:
...
...
@@ -125,9 +126,9 @@ def main():
"PRIMARY KEY(platform, arch, version, provider, status))"
)
c
.
execute
(
"CREATE TABLE stats(date TEXT
PRIMARY KEY
, "
"
num_requests INTEGER,
platform TEXT, language TEXT, command TEXT, "
"
service TEXT
)"
"CREATE TABLE stats(date TEXT
, num_requests INTEGER
, "
"platform TEXT, language TEXT, command TEXT,
service TEXT,
"
"
PRIMARY KEY (platform, language, command, service, date)
)"
)
print
(
"New database {} created."
.
format
(
abs_filename
))
...
...
tests/test_locales.py
View file @
9723be42
...
...
@@ -6,7 +6,7 @@ from twisted.internet import task
from
.
import
conftests
class
EmailService
Tests
(
unittest
.
TestCase
):
class
Locales
Tests
(
unittest
.
TestCase
):
# Fail any tests which take longer than 15 seconds.
timeout
=
15
...
...
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