Skip to content

Commit

Permalink
Allow filtering studies by num reviewers (#112)
Browse files Browse the repository at this point in the history
* feat: Allow filtering studies by num reviewers

* tests: Add num reviewer study filtering cases

* docs: Update to-do list
  • Loading branch information
bdewilde authored May 14, 2024
1 parent 4f0ab02 commit 423e2b2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
- [ ] Confirm that all email interactions (e.g. password reset) actually work
- [ ] Better handle uploaded fulltext files (really, all data artifacts saved on disk, not in the db)
- [x] Allow for multiple review owners
- [ ] Allow for assigning studies to reviewers for screening
- [ ] Allow for assigning studies to reviewers for screening?
- [ ] Integrate caching and rate limiting into API
- [ ] Add extra fields in users table, e.g. affiliation
- [ ] Improve and extend NLP functionality, just across the board
- [ ] Enable https everywhere (via [let's encrypt](https://letsencrypt.org/)?)
- [ ] Add a "deduplicate" button to front-end interface and only run dedupe jobs upon request
- [ ] Only run dedupe jobs upon request (requires a "deduplicate" button to front-end interface)
- [x] Allow for requiring multiple screeners on a configurable percentage of studies (for "rapid review" style projects)
- [ ] Add filtering studies by number of citation/fulltext reviewers
- [x] Add filtering studies by number of citation/fulltext reviewers
27 changes: 27 additions & 0 deletions colandr/apis/resources/studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ class StudiesResource(Resource):
"enum": constants.EXTRACTION_STATUSES,
"description": "filter studies to only those with matching data extraction statuses",
},
"num_citation_reviewers": {
"in": "query",
"type": "integer",
"description": "filter studies to only those with a matching number of citation reviewers",
},
"num_fulltext_reviewers": {
"in": "query",
"type": "integer",
"description": "filter studies to only those with a matching number of fulltext reviewers",
},
"tag": {
"in": "query",
"type": "string",
Expand Down Expand Up @@ -245,6 +255,12 @@ class StudiesResource(Resource):
"data_extraction_status": ma_fields.String(
load_default=None, validate=OneOf(constants.EXTRACTION_STATUSES)
),
"num_citation_reviewers": ma_fields.Int(
load_default=None, validate=Range(min=1, max=3)
),
"num_fulltext_reviewers": ma_fields.Int(
load_default=None, validate=Range(min=1, max=3)
),
"tag": ma_fields.String(load_default=None, validate=Length(max=25)),
"tsquery": ma_fields.String(load_default=None, validate=Length(max=50)),
"order_by": ma_fields.String(
Expand All @@ -269,6 +285,8 @@ def get(
citation_status,
fulltext_status,
data_extraction_status,
num_citation_reviewers,
num_fulltext_reviewers,
tag,
tsquery,
order_by,
Expand Down Expand Up @@ -409,6 +427,15 @@ def get(
models.Study.data_extraction_status == data_extraction_status
)

if num_citation_reviewers is not None:
stmt = stmt.where(
models.Study.num_citation_reviewers == num_citation_reviewers
)
if num_fulltext_reviewers is not None:
stmt = stmt.where(
models.Study.num_fulltext_reviewers == num_fulltext_reviewers
)

if tag:
stmt = stmt.where(models.Study.tags.any(tag, operator=operators.eq))

Expand Down
4 changes: 4 additions & 0 deletions tests/api/test_studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ class TestStudiesResource:
(1, {"review_id": 1, "citation_status": "excluded"}, [3]),
(1, {"review_id": 1, "fulltext_status": "included"}, [1]),
(3, {"review_id": 2, "fulltext_status": "pending"}, [4]),
(1, {"review_id": 1, "num_citation_reviewers": 1}, [1, 2, 3]),
(1, {"review_id": 1, "num_citation_reviewers": 2}, []),
(1, {"review_id": 2, "num_fulltext_reviewers": 1}, []),
(1, {"review_id": 2, "num_fulltext_reviewers": 2}, [4]),
(2, {"review_id": 1, "tag": "TAG1"}, [1, 2]),
(2, {"review_id": 1, "tag": "TAG2"}, [2]),
(2, {"review_id": 1, "tsquery": "TITLE1"}, [1]),
Expand Down

0 comments on commit 423e2b2

Please sign in to comment.