Skip to content

Instantly share code, notes, and snippets.

View guyjacks's full-sized avatar

Guy L Jacks guyjacks

View GitHub Profile
modelA
---
id
entity_id
...
entity
---
id
...
modelA
---
id
name
entity_type (B or C)
entity_id
modelB
---
id
function reloadCases (afterLoad){
console.log('reloadCases()');
// Reload cases and executes the given afterLoad callback when done.
casesResource.query().$promise.then(function (someCases) {
console.log('reloadCases()', someCases);
ctrl.cases = someCases;
$timeout(updateCases, 100);
!!afterLoad ? afterLoad.call() : null;
});
}
WITH matched_rule AS (
SELECT U0."id"
FROM "mtx_rule" U0
INNER JOIN "mtx_biopsyrule" U1 ON (U0."id" = U1."rule_id")
WHERE U1."biopsy_id" = 3
),
top_biopsies AS (
SELECT "mtx_biopsyrule"."biopsy_id" AS id
,COUNT("mtx_biopsyrule"."rule_id") AS "num_common_rules"
FROM "mtx_biopsyrule"
WITH selected_biopsy_rules AS (
SELECT U0."id"
FROM "mtx_rule" U0
INNER JOIN "mtx_biopsyrule" U1 ON (U0."id" = U1."rule_id")
WHERE U1."biopsy_id" = 3
)
SELECT
"mtx_biopsy"."id",
"mtx_biopsy"."days_to_death",
"mtx_patient"."is_deceased",
WITH matched_rule AS (
SELECT U0."id"
FROM "mtx_rule" U0
INNER JOIN "mtx_biopsyrule" U1 ON (U0."id" = U1."rule_id")
WHERE U1."biopsy_id" = 3
)
SELECT
"mtx_biopsy"."id",
"mtx_biopsy"."days_to_death",
"mtx_patient"."is_deceased",
def get_biopsy_rules(self):
query = '''
with rule_set AS (
select rule_id AS id from mtx_biopsyrule where biopsy_id=3
)
SELECT
biopsyrule.id AS id,
biopsyrule.rule_id as rule_id,
generule.mutated as mutated,
gene.name as name
import time
from matchtx_api.mtx.models import Case
start = time.time()
case = Case.objects.get(pk=1)
for rule in case.selected_biopsy.rules.all():
print(rule.name())
stop = time.time()
print ('done')
print('took {0} seconds'.format((stop - start) * 1000.0))
# viewset
class DealViewSet(viewsets.ModelViewSet):
serializer_class = serializers.DealSerializer
lookup_field = 'client_generated_id'
def get_queryset(self):
case_id = self.kwargs['case_client_generated_id']
return Deal.objects.filter(case__client_generated_id=case_id)
# STACK OVERFLOW - Problem #2
django.request: ERROR: Internal Server Error: /cases/c34dbf68-4593-45d5-af4b-5e886371399c/deals/
Traceback (most recent call last):
File "/Users/guyjacks/.pyenv/versions/adr-api/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/guyjacks/.pyenv/versions/adr-api/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/guyjacks/.pyenv/versions/adr-api/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/guyjacks/.pyenv/versions/adr-api/lib/python3.4/site-packages/rest_framework/viewsets.py", line 83, in view
return self.dispatch(request, *args, **kwargs)