Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sick-Beard
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
Sick-Beard
Commits
6ca25fd3
Commit
6ca25fd3
authored
May 3, 2011
by
Nic Wolfe
Browse files
Options
Downloads
Patches
Plain Diff
Make RSS lookup caching more efficient
parent
64066a94
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sickbeard/scene_exceptions.py
+12
-3
12 additions, 3 deletions
sickbeard/scene_exceptions.py
tests/scene_helpers_tests.py
+19
-1
19 additions, 1 deletion
tests/scene_helpers_tests.py
with
31 additions
and
4 deletions
sickbeard/scene_exceptions.py
+
12
−
3
View file @
6ca25fd3
...
...
@@ -85,12 +85,21 @@ def retrieve_exceptions():
exception_dict
[
tvdb_id
]
=
alias_list
myDB
=
db
.
DBConnection
(
"
cache.db
"
)
myDB
.
action
(
"
DELETE FROM scene_exceptions WHERE 1=1
"
)
changed_exceptions
=
False
# write all the exceptions we got off the net into the database
for
cur_tvdb_id
in
exception_dict
:
# get a list of the existing exceptions for this ID
existing_exceptions
=
[
x
[
"
show_name
"
]
for
x
in
myDB
.
select
(
"
SELECT * FROM scene_exceptions WHERE tvdb_id = ?
"
,
[
cur_tvdb_id
])]
for
cur_exception
in
exception_dict
[
cur_tvdb_id
]:
# if this exception isn't already in the DB then add it
if
cur_exception
not
in
existing_exceptions
:
myDB
.
action
(
"
INSERT INTO scene_exceptions (tvdb_id, show_name) VALUES (?,?)
"
,
[
cur_tvdb_id
,
cur_exception
])
changed_exceptions
=
True
# since this could invalidate the results of the cache we clear it out after updating
if
changed_exceptions
:
name_cache
.
clearCache
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/scene_helpers_tests.py
+
19
−
1
View file @
6ca25fd3
...
...
@@ -3,7 +3,7 @@ import unittest
import
sys
,
os
.
path
sys
.
path
.
append
(
os
.
path
.
abspath
(
'
..
'
))
from
sickbeard
import
show_name_helpers
,
scene_exceptions
,
common
from
sickbeard
import
show_name_helpers
,
scene_exceptions
,
common
,
name_cache
import
sickbeard
from
sickbeard
import
db
...
...
@@ -108,6 +108,24 @@ class SceneExceptionTestCase(unittest.TestCase):
def
test_sceneExceptionByNameEmpty
(
self
):
self
.
assertEqual
(
scene_exceptions
.
get_scene_exception_by_name
(
'
nothing useful
'
),
None
)
def
test_sceneExceptionsResetNameCache
(
self
):
# clear the exceptions
myDB
=
db
.
DBConnection
(
"
cache.db
"
)
myDB
.
action
(
"
DELETE FROM scene_exceptions
"
)
# put something in the cache
name_cache
.
addNameToCache
(
'
Cached Name
'
,
0
)
# updating should clear the cache so our previously "Cached Name" won't be in there
scene_exceptions
.
retrieve_exceptions
()
self
.
assertEqual
(
name_cache
.
retrieveNameFromCache
(
'
Cached Name
'
),
None
)
# put something in the cache
name_cache
.
addNameToCache
(
'
Cached Name
'
,
0
)
# updating should not clear the cache this time since our exceptions didn't change
scene_exceptions
.
retrieve_exceptions
()
self
.
assertEqual
(
name_cache
.
retrieveNameFromCache
(
'
Cached Name
'
),
0
)
if
__name__
==
'
__main__
'
:
...
...
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