aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-20 20:08:43 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-20 20:08:43 -0700
commitab9fe881c0531b5dd4e2a648e65d4d04b991b807 (patch)
treecf55b247d26a0e475cd553c3cef2b101ce41b622
parent3ebea73882a35ea1e892899d959efaed0264ec66 (diff)
downloadfatcat-ab9fe881c0531b5dd4e2a648e65d4d04b991b807.tar.gz
fatcat-ab9fe881c0531b5dd4e2a648e65d4d04b991b807.zip
hide abstracts and refs in release expansions
-rw-r--r--CHANGELOG.md3
-rw-r--r--python/tests/api_files.py2
-rw-r--r--python/tests/api_filesets.py2
-rw-r--r--python/tests/api_webcaptures.py2
-rw-r--r--rust/src/entity_crud.rs15
5 files changed, 21 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 466d5502..5e9d2814 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -62,6 +62,9 @@ This version includes some backward-incompatible changes.
`number`
- `ark_id` (for ARK identifiers) and `mag_id` (for Microsoft Academic Graph
identifiers) added to releases (under `ext_id`)
+- allow expanding `releases` for file, fileset, and webcapture entities.
+ Expanded release entities have their abstracts and refs hidden by default
+ (for performance)
## [0.2.2] - 2019-05-08
diff --git a/python/tests/api_files.py b/python/tests/api_files.py
index 32d4a6ee..dd10058b 100644
--- a/python/tests/api_files.py
+++ b/python/tests/api_files.py
@@ -66,6 +66,8 @@ def test_file_examples(api):
f1 = api.get_file('aaaaaaaaaaaaamztaaaaaaaaam', expand="releases")
assert f1.sha256 == "ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362"
assert f1.releases[0].ident
+ assert f1.releases[0].abstracts is None
+ assert f1.releases[0].refs is None
# expansion (back from release)
r1 = api.get_release(f1.releases[0].ident, expand="files")
diff --git a/python/tests/api_filesets.py b/python/tests/api_filesets.py
index 94aa575d..48f58cc8 100644
--- a/python/tests/api_filesets.py
+++ b/python/tests/api_filesets.py
@@ -82,6 +82,8 @@ def test_fileset_examples(api):
assert fs3.manifest[1].md5 == 'f4de91152c7ab9fdc2a128f962faebff'
assert fs3.manifest[1].extra['mimetype'] == 'application/gzip'
assert fs3.releases[0].ident
+ assert fs3.releases[0].abstracts is None
+ assert fs3.releases[0].refs is None
def test_bad_fileset(api):
diff --git a/python/tests/api_webcaptures.py b/python/tests/api_webcaptures.py
index 78549b0f..7734398b 100644
--- a/python/tests/api_webcaptures.py
+++ b/python/tests/api_webcaptures.py
@@ -101,6 +101,8 @@ def test_webcapture_examples(api):
assert wc3.cdx[1].sha1 == 'a637f1d27d9bcb237310ed29f19c07e1c8cf0aa5'
assert wc3.archive_urls[1].rel == 'warc'
assert wc3.releases[0].ident
+ assert wc3.releases[0].abstracts is None
+ assert wc3.releases[0].refs is None
def test_bad_webcapture(api):
diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs
index f348e8dc..240a7d92 100644
--- a/rust/src/entity_crud.rs
+++ b/rust/src/entity_crud.rs
@@ -1045,6 +1045,9 @@ impl EntityCrud for FileEntity {
}
// Could potentially hit this code path when expanding a redirected entity or bare
// revision. In either case, `self.release_ids` should already be set.
+ let mut hide_flags = HideFlags::none();
+ hide_flags.abstracts = true;
+ hide_flags.refs = true;
if expand.releases && self.release_ids.is_some() {
if let Some(release_ids) = &self.release_ids {
self.releases = Some(
@@ -1054,7 +1057,7 @@ impl EntityCrud for FileEntity {
Ok(ReleaseEntity::db_get(
conn,
FatcatId::from_str(release_id)?,
- HideFlags::none(),
+ hide_flags,
)?)
})
.collect::<Result<Vec<ReleaseEntity>>>()?,
@@ -1245,6 +1248,9 @@ impl EntityCrud for FilesetEntity {
}
// Could potentially hit this code path when expanding a redirected entity or bare
// revision. In either case, `self.release_ids` should already be set.
+ let mut hide_flags = HideFlags::none();
+ hide_flags.abstracts = true;
+ hide_flags.refs = true;
if expand.releases && self.release_ids.is_some() {
if let Some(release_ids) = &self.release_ids {
self.releases = Some(
@@ -1254,7 +1260,7 @@ impl EntityCrud for FilesetEntity {
Ok(ReleaseEntity::db_get(
conn,
FatcatId::from_str(release_id)?,
- HideFlags::none(),
+ hide_flags,
)?)
})
.collect::<Result<Vec<ReleaseEntity>>>()?,
@@ -1482,6 +1488,9 @@ impl EntityCrud for WebcaptureEntity {
}
// Could potentially hit this code path when expanding a redirected entity or bare
// revision. In either case, `self.release_ids` should already be set.
+ let mut hide_flags = HideFlags::none();
+ hide_flags.abstracts = true;
+ hide_flags.refs = true;
if expand.releases && self.release_ids.is_some() {
if let Some(release_ids) = &self.release_ids {
self.releases = Some(
@@ -1491,7 +1500,7 @@ impl EntityCrud for WebcaptureEntity {
Ok(ReleaseEntity::db_get(
conn,
FatcatId::from_str(release_id)?,
- HideFlags::none(),
+ hide_flags,
)?)
})
.collect::<Result<Vec<ReleaseEntity>>>()?,