History

Add db_size attribute in doc manifest

Thibaut committed 11 years ago

Commit a59ef1c1 parent 456c4cb3 files · +11 −1Browse files

Unified · Split

3 files
  1. assets/javascripts/models/doc.coffee +1 −1
  2. lib/docs/core/manifest.rb +5 −0
  3. test/lib/docs/core/manifest_test.rb +5 −0
assets/javascripts/models/doc.coffee+1−1
@@ -1,5 +1,5 @@
11 class app.models.Doc extends app.Model
2− # Attributes: name, slug, type, version, index_path, db_path, mtime
2+ # Attributes: name, slug, type, version, index_path, db_path, db_size, mtime
33
44 constructor: ->
55 super
lib/docs/core/manifest.rb+5−0
@@ -16,6 +16,7 @@ module Docs · 15 unmodified lines
1616 def as_json
1717 indexed_docs.map(&:as_json).each do |json|
1818 json[:mtime] = doc_mtime(json)
19+ json[:db_size] = doc_db_size(json)
1920 end
2021 end
2122
@@ -34,5 +35,9 @@ module Docs · 12 unmodified lines
3435 def doc_mtime(doc)
3536 [@store.mtime(doc[:index_path]).to_i, @store.mtime(doc[:db_path]).to_i].max
3637 end
38+
39+ def doc_db_size(doc)
40+ @store.size(doc[:db_path])
41+ end
3742 end
3843 end
test/lib/docs/core/manifest_test.rb+5−0
@@ -78,6 +78,11 @@ class ManifestTest < MiniTest::Spec · 77 unmodified lines
7878 mtime_index, mtime_db = mtime_db, mtime_index
7979 assert_equal mtime_db.to_i, manifest.as_json.first[:mtime]
8080 end
81+
82+ it "adds a :db_size attribute" do
83+ stub(store).size(db_path) { 42 }
84+ assert_equal 42, manifest.as_json.first[:db_size]
85+ end
8186 end
8287
8388 context "when the doc doesn't have an index" do