Skip to content

Commit 1cf2d25

Browse files
authored
Merge pull request #53 from haniffalab/feat/is_listed
add is_listed field to study
2 parents 2c1e943 + 2bdf95c commit 1cf2d25

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

config/functions.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,16 @@ module.exports = {
162162
id: { $in: ids },
163163
};
164164
}
165-
165+
166+
// If not providing a study id, return only datasets from studies that are listed
167+
if (!ctx.query.filters?.study?.id?.$eq) {
168+
ctx.query.filters = {
169+
...ctx.query.filters,
170+
study: {
171+
is_listed: true },
172+
};
173+
}
174+
166175
const datasets = await strapi.entityService.findMany('api::dataset.dataset', {
167176
fields: [ontologyField],
168177
populate: {

src/api/dataset/controllers/dataset.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ module.exports = createCoreController('api::dataset.dataset', ({ strapi }) => ({
3030
};
3131
}
3232

33+
// If not providing a study id, return only datasets from studies that are listed
34+
if (!ctx.query.filters?.study?.id?.$eq) {
35+
ctx.query.filters = {
36+
...ctx.query.filters,
37+
study: {
38+
is_listed: true },
39+
};
40+
}
41+
3342
ctx.query = {
3443
...ctx.query,
3544
fields: [

src/api/study/content-types/study/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
"type": "component",
8787
"repeatable": true,
8888
"component": "data.resource"
89+
},
90+
"is_listed": {
91+
"type": "boolean",
92+
"default": true
8993
}
9094
}
9195
}

src/api/study/controllers/study.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ module.exports = createCoreController('api::study.study', ({ strapi }) => ({
2929
};
3030
}
3131

32+
ctx.query.filters = {
33+
...ctx.query.filters,
34+
is_listed: true,
35+
};
36+
3237
ctx.query = {
3338
...ctx.query,
3439
fields: [

0 commit comments

Comments
 (0)