Skip to content

Commit

Permalink
Merge e0b5f43 into 8e78058
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Mar 30, 2022
2 parents 8e78058 + e0b5f43 commit 5e503cd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 43 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ End-User Summary
================

- Fixing bug in XLSX export (#417)
- Fixing problem with multi-sample queries (#419)

Full Change List
================
Expand All @@ -19,6 +20,9 @@ Full Change List
- Fixing issue with ``fa-solid:refresh`` icon (#409)
- Fixing page titles (#409)
- Fixing bug in XLSX export (#417)
- Fixing problem with multi-sample queries (#419).
This is done by rolling back adding the ``_ClosingWrapper`` class.
We will need a different approach for the queries than was previously attempted here.

------
v1.1.1
Expand Down
66 changes: 23 additions & 43 deletions variants/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,17 +1662,6 @@ def _chunked(arr, max_size):
return chunks


class _ClosingWrapper(object):
def __init__(self, wrapped):
self.wrapped = wrapped

def fetchall(self):
return self.wrapped

def close(self):
pass


class CasePrefetchQuery:
builder = QueryPartsBuilder

Expand All @@ -1693,39 +1682,30 @@ def run(self, kwargs):
column("alternative"),
column("family_name"),
]
result = []
chunks = _chunked(self.cases, settings.QUERY_MAX_UNION)
for chunk in chunks:
stmts = []
for case in chunk:
comp_het_index = kwargs.get("compound_recessive_indices", {}).get(case.name)
recessive_index = kwargs.get("recessive_indices", {}).get(case.name)
if comp_het_index and self.query_id is None:
# Set the current compound recessive index
kwargs["compound_recessive_index"] = comp_het_index
combiner = CompHetCombiner(case, self.builder)
elif recessive_index and self.query_id is None:
# Set the current compound recessive index
kwargs["compound_recessive_index"] = recessive_index
combiner = RecessiveCombiner(case, self.builder)
else: # compound recessive not in kwargs or disabled
combiner = DefaultCombiner(case, self.builder, self.query_id)
stmts.append(combiner.to_stmt(kwargs))
stmt = union(*stmts).order_by(*order_by)
if settings.DEBUG:
print(
"\n"
+ sqlparse.format(
stmt.compile(self.engine).string, reindent=True, keyword_case="upper"
)
stmts = []
for case in self.cases:
comp_het_index = kwargs.get("compound_recessive_indices", {}).get(case.name)
recessive_index = kwargs.get("recessive_indices", {}).get(case.name)
if comp_het_index and self.query_id is None:
# Set the current compound recessive index
kwargs["compound_recessive_index"] = comp_het_index
combiner = CompHetCombiner(case, self.builder)
elif recessive_index and self.query_id is None:
# Set the current compound recessive index
kwargs["compound_recessive_index"] = recessive_index
combiner = RecessiveCombiner(case, self.builder)
else: # compound recessive not in kwargs or disabled
combiner = DefaultCombiner(case, self.builder, self.query_id)
stmts.append(combiner.to_stmt(kwargs))
stmt = union(*stmts).order_by(*order_by)
if settings.DEBUG:
print(
"\n"
+ sqlparse.format(
stmt.compile(self.engine).string, reindent=True, keyword_case="upper"
)
query_res = self.engine.execute(stmt)
if len(chunks) == 1:
return query_res
else:
with contextlib.closing(query_res) as query_res:
result += list(query_res)
return _ClosingWrapper(result)
)
return self.engine.execute(stmt)


class CaseLoadPrefetchedQuery(CasePrefetchQuery):
Expand Down

0 comments on commit 5e503cd

Please sign in to comment.