Skip to content

Commit

Permalink
Merge pull request #881 from opencb/TASK-5834
Browse files Browse the repository at this point in the history
TASK-5834 - Incomplete list of cases in the individual grid
  • Loading branch information
jmjuanes authored Apr 4, 2024
2 parents 505dba6 + c94f02d commit 06a5c68
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
14 changes: 11 additions & 3 deletions src/webcomponents/family/family-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,27 @@ export default class FamilyGrid extends LitElement {
...this.query
};

// Calculate the number of cases to fetch
const casesLimit = this.table?.bootstrapTable("getOptions")?.pageSize || this._config.pageSize || 10;

// Store the current filters
this.lastFilters = {...this.filters};
this.opencgaSession.opencgaClient.families()
.search(this.filters)
.then(familyResponse => {
// Fetch Clinical Analysis ID per Family in 1 single query
const familyIds = familyResponse.responses[0].results.map(family => family.id).join(",");
const familyIds = familyResponse.responses[0].results
.map(family => family.id)
.join(",");

if (familyIds) {
this.opencgaSession.opencgaClient.clinical()
this.opencgaSession.opencgaClient
.clinical()
.search({
family: familyIds,
study: this.opencgaSession.study.fqn,
include: "id,proband.id,family.members,family.id"
include: "id,proband.id,family.members,family.id",
limit: casesLimit * 10
})
.then(caseResponse => {
familyResponse.getResults().forEach(family => {
Expand Down
15 changes: 12 additions & 3 deletions src/webcomponents/individual/individual-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,28 @@ export default class IndividualGrid extends LitElement {
...this.query
};

// Calculate the number of cases to fetch
const casesLimit = this.table?.bootstrapTable("getOptions")?.pageSize || this._config.pageSize || 10;

// Store the current filters
this.lastFilters = {...this.filters};
this.opencgaSession.opencgaClient.individuals()
.search(this.filters)
.then(individualResponse => {
// Fetch Clinical Analysis ID per individual in 1 single query
const individualIds = individualResponse.getResults().map(individual => individual.id).filter(Boolean).join(",");
const individualIds = individualResponse.getResults()
.map(individual => individual.id)
.filter(Boolean)
.join(",");

if (individualIds) {
this.opencgaSession.opencgaClient.clinical()
this.opencgaSession.opencgaClient
.clinical()
.search({
individual: individualIds,
study: this.opencgaSession.study.fqn,
include: "id,proband.id,family.members"
include: "id,proband.id,family.members",
limit: casesLimit * 10
})
.then(caseResponse => {
individualResponse.getResults().forEach(individual => {
Expand Down
13 changes: 10 additions & 3 deletions src/webcomponents/sample/sample-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export default class SampleGrid extends LitElement {
...this.query
};

// Calculate the number of cases to fetch
const casesLimit = this.table?.bootstrapTable("getOptions")?.pageSize || this._config.pageSize || 10;

// Store the current filters
this.lastFilters = {...this.filters};
this.opencgaSession.opencgaClient.samples()
Expand All @@ -197,14 +200,18 @@ export default class SampleGrid extends LitElement {
// Fetch clinical analysis to display the Case ID
const individualIds = sampleResponse.getResults()
.map(sample => sample.individualId)
.filter(Boolean).join(",");
.filter(Boolean)
.join(",");

if (individualIds) {
this.opencgaSession.opencgaClient.clinical()
this.opencgaSession.opencgaClient
.clinical()
.search(
{
individual: individualIds,
study: this.opencgaSession.study.fqn,
include: "id,proband.id,family.members"
include: "id,proband.id,family.members",
limit: casesLimit * 10
})
.then(caseResponse => {
sampleResponse.getResults().forEach(sample => {
Expand Down

0 comments on commit 06a5c68

Please sign in to comment.