-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_entries(has_enclosures=...) should be a plugin(?) #327
Comments
What about get_feeds(broken=..., updates_enabled=..., new=...)? Where do we draw the line? Is this turning into #253? (DynamoDB has rotted my brain.) |
Related: http://howto.philippkeller.com/2005/04/24/Tags-Database-schemas/, vaguely reminiscent of https://en.wikipedia.org/wiki/Star_schema; also see https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model What would reader look like if you could only filter and sort by tags?
|
So, based on various SQLite forum threads, the general conclusion seems to be "don't bother – design your schema as you normally would, and add indexes as needed later on"; in fairness, this is something I already knew, but as I said, DynamoDB has rotted my brain. I also tentatively removed has_enclosures, and it didn't remove all that much code. So:
|
Ran some benchmarks, here's a summary:
Single entry tag results.Given a $ python -c '
from reader import make_reader
reader = make_reader("db.sqlite")
for e in reader.get_entries(has_enclosures=True):
reader.set_tag(e, "has-enclosures")
print(reader.get_entry_counts())
'
EntryCounts(total=21609, read=15614, important=222, has_enclosures=3978, averages=(0.0, 6.868131868131868, 10.117808219178082)) ...and this benchmark script: export BENCH_TIME_STAT='avg min'
lines='for _ in reader.get_entries(has_enclosures=True): pass
for _ in reader.get_entries(tags=["has-enclosures"]): pass
for _ in reader.get_entries(has_enclosures=True, limit=100): pass
for _ in reader.get_entries(tags=["has-enclosures"], limit=100): pass
for _ in reader.search_entries("python", has_enclosures=True): pass
for _ in reader.search_entries("python", tags=["has-enclosures"]): pass
for _ in reader.search_entries("python", has_enclosures=True, limit=20): pass
for _ in reader.search_entries("python", tags=["has-enclosures"], limit=20): pass'
while IFS= read -r line; do
echo "# $line"
sync && sudo purge
python scripts/bench.py time snippet -r10 --snippet "$line"
done <<< "$lines" The output is:
1-2 entry tags results.Extra tags were set for read and (un)important like so: $ python -c '
from reader import make_reader
reader = make_reader("db.sqlite")
for e in reader.get_entries():
if e.read:
reader.set_tag(e, "read")
if e.important is True:
reader.set_tag(e, "important")
if e.important is False:
reader.set_tag(e, "unimportant")
' Output (same script as before, but only for the tags snippets):
20+ entry tags results.Extra tags were set for read and (un)important like so: $ python -c '
from reader import make_reader
reader = make_reader("db.sqlite")
tags = "one two three four five six seven eight nine ten eleven twelve thirteen fourteen sixteen seventeen eighteen nineteen twenty".split()
for e in reader.get_entries():
for tag in tags:
reader.set_tag(e, tag)
' Output (same script as before, but only for the tags snippets):
|
The has_enclosures filter predates entry tags, and was meant as a proxy for "is a podcast item" (which works fine, at least with the feeds I'm subscribed to).
The same functionality can be obtained with a plugin that sets a tag, then used as a filter with get_entries(tags=['.has-enclosures']).
Some arguments for this:
Removing the has_enclosures argument is a compatibility break, so it needs to be done in 4.0, #291.
The text was updated successfully, but these errors were encountered: