Add user id index to usage size keys
This commit is contained in:
parent
45d44bbf26
commit
1a9be076fa
@ -156,12 +156,13 @@ module RemoteStorage
|
||||
def log_object_size(user, directory, new_size=0, old_size=0)
|
||||
category = extract_category(directory)
|
||||
info = info_bucket.get_or_new("usage:size:#{user}:#{category}")
|
||||
|
||||
info.content_type = "text/plain"
|
||||
|
||||
size = -old_size + new_size
|
||||
size += info.data.to_i
|
||||
|
||||
info.data = size.to_s
|
||||
info.indexes.merge!({:user_id_bin => [user]})
|
||||
info.store
|
||||
end
|
||||
|
||||
|
||||
@ -111,8 +111,11 @@ describe "App with Riak backend" do
|
||||
data_bucket.get("jimmy:documents:bar").content_type.must_equal "text/plain; charset=utf-8"
|
||||
end
|
||||
|
||||
it "increases the overall category size" do
|
||||
it "increases the usage size counter" do
|
||||
info_bucket.get("usage:size:jimmy:documents").data.must_equal "35"
|
||||
|
||||
indexes = info_bucket.get("usage:size:jimmy:documents").indexes
|
||||
indexes["user_id_bin"].must_include "jimmy"
|
||||
end
|
||||
|
||||
it "indexes the data set" do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user