From mboxrd@z Thu Jan 1 00:00:00 1970 From: marcus-sup@bar-coded.net (Marcus Williams) Date: Mon, 12 Nov 2007 13:29:30 +0000 Subject: [sup-talk] Sup sources question In-Reply-To: <1194840179-sup-2716@south> References: <1194520465-sup-413@tomsk> <1194840179-sup-2716@south> Message-ID: <1194873885-sup-8903@tomsk> On 12.11.2007, William Morgan wrote: > Just curious if you managed to make this work. I sent an example to the > list a few weeks back about using console.sh to do just this sort of > thing. Yep - cleaned up all of my sources without having to resync. I wrote a little wrapper tool to do it, might clean up that and post it some time. For info, the way I did it was almost exactly the way you suggested (to be run in console.sh): # remove inbox label and add sent label on all messages coming from a # single source (id is 3) Index.ferret.search_each("source_id:3", :limit => :all) do |id, score| m = Index.build_message id puts "Modifying #{m.id}\t[#{m.labels.join ','}]" m.labels.uniq! m.labels -= [:inbox] unless m.labels.include? :starred m.labels += [:sent] puts ".......to #{m.id}\t[#{m.labels.join ','}]" Index.sync_message m end Index.ferret.optimize I did notice some messages had a lot of repeated labels. Not sure why, but calling uniq! fixed it. Marcus