Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage-1
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
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
SickRage-1
Commits
9fd8f65c
Commit
9fd8f65c
authored
Sep 10, 2015
by
Gaëtan Muller
Browse files
Options
Downloads
Patches
Plain Diff
Fix for
https://github.com/SiCKRAGETV/sickrage-issues/issues/2719
parent
97fa35dc
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
sickrage/show/History.py
+29
-18
29 additions, 18 deletions
sickrage/show/History.py
with
29 additions
and
18 deletions
sickrage/show/History.py
+
29
−
18
View file @
9fd8f65c
...
...
@@ -11,6 +11,9 @@ class History:
self
.
db
=
DBConnection
()
def
clear
(
self
):
"""
Clear all the history
"""
self
.
db
.
action
(
'
DELETE
'
'
FROM history
'
...
...
@@ -18,6 +21,13 @@ class History:
)
def
get
(
self
,
limit
=
100
,
action
=
None
):
"""
:param limit: The maximum number of elements to return
:param action: The type of action to filter in the history. Either
'
downloaded
'
or
'
snatched
'
. Anything else or
no value will return everything (up to ``limit``)
:return: The last ``limit`` elements of type ``action`` in the history
"""
action
=
action
.
lower
()
if
isinstance
(
action
,
str
)
else
''
limit
=
int
(
limit
)
...
...
@@ -26,27 +36,24 @@ class History:
elif
action
==
'
snatched
'
:
actions
=
Quality
.
SNATCHED
else
:
actions
=
Quality
.
SNATCHED
+
Quality
.
DOWNLOADED
actions
=
[]
if
limit
==
0
:
results
=
self
.
db
.
select
(
'
SELECT h.*, show_name
'
'
FROM history h, tv_shows s
'
common_sql
=
'
SELECT h.*, show_name
'
\
'
FROM history h, tv_shows s
'
\
'
WHERE h.showid = s.indexer_id
'
'
AND action in (
'
+
'
,
'
.
join
([
'
?
'
]
*
len
(
actions
))
+
'
)
'
'
ORDER BY date DESC
'
,
actions
)
filter_sql
=
'
AND action in (
'
+
'
,
'
.
join
([
'
?
'
]
*
len
(
actions
))
+
'
)
'
order_sql
=
'
ORDER BY date DESC
'
if
limit
==
0
:
if
len
(
actions
)
>
0
:
results
=
self
.
db
.
select
(
common_sql
+
filter_sql
+
order_sql
,
actions
)
else
:
results
=
self
.
db
.
select
(
'
SELECT h.*, show_name
'
'
FROM history h, tv_shows s
'
'
WHERE h.showid = s.indexer_id
'
'
AND action in (
'
+
'
,
'
.
join
([
'
?
'
]
*
len
(
actions
))
+
'
)
'
'
ORDER BY date DESC
'
'
LIMIT ?
'
,
actions
+
[
limit
]
)
results
=
self
.
db
.
select
(
common_sql
+
order_sql
)
else
:
if
len
(
actions
)
>
0
:
results
=
self
.
db
.
select
(
common_sql
+
filter_sql
+
order_sql
+
'
LIMIT ?
'
,
actions
+
[
limit
])
else
:
results
=
self
.
db
.
select
(
common_sql
+
order_sql
+
'
LIMIT ?
'
,
[
limit
])
data
=
[]
for
result
in
results
:
...
...
@@ -65,6 +72,10 @@ class History:
return
data
def
trim
(
self
):
"""
Remove all elements older than 30 days from the history
"""
self
.
db
.
action
(
'
DELETE
'
'
FROM history
'
...
...
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