Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | 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 | |
| 3 | 3 | |
| 4 | 4 | constructor: -> |
| 5 | 5 | super |
| @@ -16,6 +16,7 @@ module Docs · 15 unmodified lines | ||
| 16 | 16 | def as_json |
| 17 | 17 | indexed_docs.map(&:as_json).each do |json| |
| 18 | 18 | json[:mtime] = doc_mtime(json) |
| 19 | + json[:db_size] = doc_db_size(json) | |
| 19 | 20 | end |
| 20 | 21 | end |
| 21 | 22 | |
| @@ -34,5 +35,9 @@ module Docs · 12 unmodified lines | ||
| 34 | 35 | def doc_mtime(doc) |
| 35 | 36 | [@store.mtime(doc[:index_path]).to_i, @store.mtime(doc[:db_path]).to_i].max |
| 36 | 37 | end |
| 38 | + | |
| 39 | + def doc_db_size(doc) | |
| 40 | + @store.size(doc[:db_path]) | |
| 41 | + end | |
| 37 | 42 | end |
| 38 | 43 | end |
| @@ -78,6 +78,11 @@ class ManifestTest < MiniTest::Spec · 77 unmodified lines | ||
| 78 | 78 | mtime_index, mtime_db = mtime_db, mtime_index |
| 79 | 79 | assert_equal mtime_db.to_i, manifest.as_json.first[:mtime] |
| 80 | 80 | 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 | |
| 81 | 86 | end |
| 82 | 87 | |
| 83 | 88 | context "when the doc doesn't have an index" do |