Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Simple OPDS
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
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
Mirror
Simple OPDS
Commits
6939767a
Commit
6939767a
authored
Mar 16, 2017
by
Dmitry Shelepnev
Browse files
Options
Downloads
Patches
Plain Diff
Add sopds_util pg_optimize cmd for PostgreSQL Optimization
parent
886bd46c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
opds_catalog/management/commands/sopds_util.py
+10
-2
10 additions, 2 deletions
opds_catalog/management/commands/sopds_util.py
opds_catalog/opdsdb.py
+19
-8
19 additions, 8 deletions
opds_catalog/opdsdb.py
opds_catalog/settings.py
+1
-2
1 addition, 2 deletions
opds_catalog/settings.py
with
30 additions
and
12 deletions
opds_catalog/management/commands/sopds_util.py
+
10
−
2
View file @
6939767a
from
django.core.management.base
import
BaseCommand
from
django.core.management
import
call_command
from
django.db
import
transaction
from
django.db
import
connection
from
django.conf
import
settings
as
main_settings
from
opds_catalog
import
opdsdb
...
...
@@ -14,7 +15,7 @@ class Command(BaseCommand):
verbose
=
False
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'
command
'
,
action
=
"
store
"
,
nargs
=
'
*
'
,
help
=
'
Use [ clear | info | save_mygenres | load_mygenres | setconf | getconf ]
'
)
parser
.
add_argument
(
'
command
'
,
action
=
"
store
"
,
nargs
=
'
*
'
,
help
=
'
Use [ clear | info | save_mygenres | load_mygenres | setconf | getconf
| pg_optimize
]
'
)
parser
.
add_argument
(
'
--verbose
'
,
action
=
'
store_true
'
,
dest
=
'
verbose
'
,
default
=
False
,
help
=
'
Set verbosity level for books collection scan.
'
)
parser
.
add_argument
(
'
--nogenres
'
,
action
=
'
store_true
'
,
dest
=
'
nogenres
'
,
default
=
False
,
help
=
'
Not install genres fom fixtures.
'
)
...
...
@@ -40,6 +41,8 @@ class Command(BaseCommand):
elif
action
==
"
getconf
"
:
self
.
confparam
=
options
[
'
command
'
][
1
]
if
len
(
options
[
'
command
'
])
>
1
else
None
self
.
getconf
(
self
.
confparam
)
elif
action
==
"
pg_optimize
"
:
self
.
pg_optimize
()
def
clear
(
self
):
with
transaction
.
atomic
():
...
...
@@ -47,6 +50,7 @@ class Command(BaseCommand):
if
not
self
.
nogenres
:
call_command
(
'
loaddata
'
,
'
genre.json
'
,
app_label
=
'
opds_catalog
'
)
Counter
.
objects
.
update_known_counters
()
opdsdb
.
pg_optimize
(
False
)
def
info
(
self
):
Counter
.
objects
.
update_known_counters
()
...
...
@@ -78,5 +82,9 @@ class Command(BaseCommand):
else
:
call_command
(
'
constance
'
,
'
list
'
,
app_label
=
'
opds_catalog
'
)
def
pg_optimize
(
self
):
opdsdb
.
pg_optimize
(
True
)
This diff is collapsed.
Click to expand it.
opds_catalog/opdsdb.py
+
19
−
8
View file @
6939767a
...
...
@@ -42,6 +42,17 @@ unknown_genre=_(unknown_genre_en)
#
utfhigh
=
re
.
compile
(
u
'
[
\U00010000
-
\U0010ffff
]
'
)
def
pg_optimize
(
verbose
=
False
):
"""
TODO: Table optimizations for Postgre
"""
if
connection
.
vendor
!=
'
postgresql
'
:
if
verbose
:
print
(
'
No PostgreSql connection backend detected...
'
)
else
:
cursor
=
connection
.
cursor
()
cursor
.
execute
(
'
alter table opds_catalog_book SET ( fillfactor = 50)
'
)
cursor
.
execute
(
'
VACUUM FULL opds_catalog_book
'
)
print
(
'
PostgreSql tables internal structure optimized...
'
)
def
clear_all
(
verbose
=
False
):
cursor
=
connection
.
cursor
()
cursor
.
execute
(
'
delete from opds_catalog_bseries
'
)
...
...
This diff is collapsed.
Click to expand it.
opds_catalog/settings.py
+
1
−
2
View file @
6939767a
...
...
@@ -28,7 +28,6 @@ from django.dispatch import receiver
# translation.activate(new_value)
# print(new_value)
def
constance_update_all
():
pass
...
...
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