Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Bryan Kaperick
jio
Commits
86942633
Commit
86942633
authored
Jul 06, 2018
by
Bryan Kaperick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed allDocs implementation to rely more on QueryStorage's allDocs.
parent
9bf585e5
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
393 additions
and
376 deletions
+393
-376
src/jio.storage/historystorage.js
src/jio.storage/historystorage.js
+28
-61
test/jio.storage/historystorage.tests.js
test/jio.storage/historystorage.tests.js
+365
-315
No files found.
src/jio.storage/historystorage.js
View file @
86942633
...
@@ -236,7 +236,6 @@
...
@@ -236,7 +236,6 @@
attachment_promises
[
entry
.
value
.
name
]
=
attachment_promises
[
entry
.
value
.
name
]
=
substorage
.
getAttachment
(
entry
.
id
,
entry
.
value
.
name
);
substorage
.
getAttachment
(
entry
.
id
,
entry
.
value
.
name
);
}
}
return
RSVP
.
hash
(
attachment_promises
);
return
RSVP
.
hash
(
attachment_promises
);
});
});
};
};
...
@@ -256,7 +255,6 @@
...
@@ -256,7 +255,6 @@
return
substorage
.
putAttachment
(
timestamp
,
name
,
blob
);
return
substorage
.
putAttachment
(
timestamp
,
name
,
blob
);
});
});
};
};
HistoryStorage
.
prototype
.
getAttachment
=
function
(
id
,
name
)
{
HistoryStorage
.
prototype
.
getAttachment
=
function
(
id
,
name
)
{
if
(
this
.
_include_revisions
)
{
if
(
this
.
_include_revisions
)
{
...
@@ -335,10 +333,11 @@
...
@@ -335,10 +333,11 @@
HistoryStorage
.
prototype
.
repair
=
function
()
{
HistoryStorage
.
prototype
.
repair
=
function
()
{
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
);
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
);
};
};
HistoryStorage
.
prototype
.
hasCapacity
=
function
()
{
HistoryStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
)
;
return
name
===
'
list
'
||
name
===
'
include
'
;
};
};
HistoryStorage
.
prototype
.
buildQuery
=
function
(
options
)
{
HistoryStorage
.
prototype
.
buildQuery
=
function
(
options
)
{
// Set default values
// Set default values
if
(
options
===
undefined
)
{
options
=
{};
}
if
(
options
===
undefined
)
{
options
=
{};
}
...
@@ -348,41 +347,22 @@
...
@@ -348,41 +347,22 @@
if
(
options
.
include_revisions
===
undefined
)
{
if
(
options
.
include_revisions
===
undefined
)
{
options
.
include_revisions
=
false
;
options
.
include_revisions
=
false
;
}
}
options
.
sort_on
.
push
([
"
timestamp
"
,
"
descending
"
]);
options
.
query
=
jIO
.
QueryFactory
.
create
(
options
.
query
);
options
.
query
=
jIO
.
QueryFactory
.
create
(
options
.
query
);
var
meta_options
,
var
meta_options
=
{
include_revs
=
this
.
_include_revisions
,
doc_id_name
,
timestamp_name
;
// Query for all edits
meta_options
=
{
query
:
""
,
query
:
""
,
sort_on
:
options
.
sort_on
,
sort_on
:
[[
"
timestamp
"
,
"
descending
"
]]
,
select_list
:
[
"
doc
"
,
"
op
"
,
"
doc_id
"
]
select_list
:
[
"
doc
"
,
"
op
"
,
"
doc_id
"
]
};
},
include_revs
=
this
.
_include_revisions
;
return
this
.
_sub_storage
.
allDocs
(
meta_options
)
return
this
.
_sub_storage
.
allDocs
(
meta_options
)
.
push
(
function
(
results
)
{
.
push
(
function
(
results
)
{
results
=
results
.
data
.
rows
;
results
=
results
.
data
.
rows
;
var
seen
=
{},
var
seen
=
{},
query_matches
,
docs_to_query
,
docs_to_query
,
i
;
i
;
doc_id_name
=
"
_doc_id
"
;
timestamp_name
=
"
_timestamp
"
;
for
(
i
=
0
;
i
<
results
.
length
;
i
+=
1
)
{
if
(
results
[
i
].
value
.
op
===
"
put
"
)
{
while
(
results
[
i
].
value
.
doc
.
hasOwnProperty
(
doc_id_name
))
{
doc_id_name
=
"
_
"
+
doc_id_name
;
}
while
(
results
[
i
].
value
.
doc
.
hasOwnProperty
(
timestamp_name
))
{
timestamp_name
=
"
_
"
+
timestamp_name
;
}
}
}
if
(
include_revs
)
{
if
(
include_revs
)
{
// We only query on versions mapping to puts or putAttachments
// We only query on versions mapping to puts or putAttachments
...
@@ -412,6 +392,8 @@
...
@@ -412,6 +392,8 @@
}
}
return
docum
;
return
docum
;
}
}
// If most recent metadata edit before the attachment edit
// was a remove, then leave doc empty
if
(
results
[
i
].
value
.
op
===
"
remove
"
)
{
if
(
results
[
i
].
value
.
op
===
"
remove
"
)
{
return
docum
;
return
docum
;
}
}
...
@@ -455,7 +437,7 @@
...
@@ -455,7 +437,7 @@
}
}
return
docum
;
return
docum
;
}
}
if
(
results
[
i
].
value
.
doc_id
===
"
remove
"
)
{
if
(
results
[
i
].
value
.
op
===
"
remove
"
)
{
// If most recent edit on document was a remove before
// If most recent edit on document was a remove before
// this attachment, then don't include attachment in query
// this attachment, then don't include attachment in query
return
false
;
return
false
;
...
@@ -467,45 +449,30 @@
...
@@ -467,45 +449,30 @@
return
false
;
return
false
;
});
});
}
}
docs_to_query
=
results
docs_to_query
=
results
// Filter out all docs flagged as false in previous map call
// Filter out all docs flagged as false in previous map call
.
filter
(
function
(
docum
)
{
.
filter
(
function
(
docum
)
{
return
docum
;
return
docum
;
})
})
.
map
(
function
(
docum
)
{
// Save timestamp and id information for retrieval at the end of
// buildQuery
docum
.
value
.
doc
[
timestamp_name
]
=
docum
.
id
;
docum
.
value
.
doc
[
doc_id_name
]
=
docum
.
value
.
doc_id
;
return
docum
.
value
.
doc
;
});
// Return timestamp and id information from query
// Put into correct format to be passed back to query storage
options
.
select_list
.
push
(
doc_id_name
);
.
map
(
function
(
docum
)
{
options
.
select_list
.
push
(
timestamp_name
);
docum
.
doc
=
docum
.
value
.
doc
;
docum
.
id
=
docum
.
value
.
doc_id
;
delete
docum
.
value
.
doc_id
;
delete
docum
.
value
.
op
;
if
(
options
.
include_docs
)
{
docum
.
doc
=
docum
.
value
.
doc
;
}
else
{
docum
.
doc
=
{};
}
// Sort on timestamp with updated timestamp_name
docum
.
value
=
{};
options
.
sort_on
[
options
.
sort_on
.
length
-
1
]
=
[
return
docum
;
timestamp_name
,
"
descending
"
});
];
return
docs_to_query
;
query_matches
=
options
.
query
.
exec
(
docs_to_query
,
options
);
return
query_matches
;
})
// Format the results of the query, and return
.
push
(
function
(
query_matches
)
{
return
query_matches
.
map
(
function
(
docum
)
{
var
doc_id
=
docum
[
doc_id_name
],
time
=
docum
[
timestamp_name
];
delete
docum
[
timestamp_name
];
delete
docum
[
doc_id_name
];
return
{
doc
:
{},
value
:
docum
,
id
:
doc_id
,
timestamp
:
time
};
});
});
});
};
};
...
...
test/jio.storage/historystorage.tests.js
View file @
86942633
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment