From: grant@antiflux.org (Grant Hollingworth)
Subject: [sup-talk] [PATCH] return sources in id-order, with non-archived sources first
Date: Fri, 18 Jan 2008 12:06:49 -0500 [thread overview]
Message-ID: <1200675726-sup-4860@spooky.local> (raw)
To speed up the user's view of polling, deal with sources that affect the
inbox before (for example) large mailing lists. It seemed tidier to implement
this in Index rather than PollManager.
I changed "@sources.values" to "sources" in some other methods for clarity,
which I think in this case outweighs lost efficiency.
---
lib/sup/index.rb | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index 1997c92..b2a1612 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -125,9 +125,13 @@ EOS
@sources[source.id] = source
end
- def source_for uri; @sources.values.find { |s| s.is_source_for? uri }; end
- def usual_sources; @sources.values.find_all { |s| s.usual? }; end
- def sources; @sources.values; end
+ def sources
+ ## favour the inbox by listing non-archived sources first
+ @sources.values.sort_by {|s| s.id }.partition {|s| !s.archived? }.flatten
+ end
+
+ def source_for uri; sources.find { |s| s.is_source_for? uri }; end
+ def usual_sources; sources.find_all { |s| s.usual? }; end
def load_index dir=File.join(@dir, "ferret")
if File.exists? dir
@@ -512,7 +516,7 @@ protected
File.chmod 0600, fn
FileUtils.mv fn, bakfn, :force => true unless File.exists?(bakfn) && File.size(fn) == 0
end
- Redwood::save_yaml_obj @sources.values.sort_by { |s| s.id.to_i }, fn, true
+ Redwood::save_yaml_obj sources.sort_by { |s| s.id.to_i }, fn, true
File.chmod 0600, fn
end
@sources_dirty = false
--
1.5.3.7
next reply other threads:[~2008-01-18 17:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-18 17:06 Grant Hollingworth [this message]
2008-01-25 5:27 ` William Morgan
2008-01-25 15:04 ` Grant Hollingworth
2008-02-03 0:58 ` William Morgan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1200675726-sup-4860@spooky.local \
--to=grant@antiflux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox