Skip to content

Commit

Permalink
-> Front page cleanup
Browse files Browse the repository at this point in the history
-> Flex boxes are amazing
-> database-refresh and -setup now take an optional command line argument to indicate if they'll use the local seed file or not
-> Fetching homepage counts from Collections instead of Solr
  • Loading branch information
s-paquette committed Aug 21, 2020
1 parent 1e8ea22 commit 69a291b
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 42 deletions.
37 changes: 15 additions & 22 deletions idc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,27 @@
# The site's homepage
@never_cache
def landing_page(request):
counts = get_collex_metadata(None, None, 0, True, False, with_derived=False, facets=["BodyPartExamined"])
collex = Collection.objects.filter(active=True).values()

facets = counts['facets']
sapien_counts = {}

exclusions = ["Undefined", "None", "Thorax_1Head_Nec", "Chestabdpelvis", "Tspine"]

sapien_counts = {
"Colorectal": {
'site': "Colorectal",
'cases': 0,
'fileCount': 0
}
changes = {
'Renal': 'Kidney',
'Head-Neck': 'Head and Neck',
'Colon': 'Colorectal',
'Rectum': 'Colorectal'
}

for x in facets:
for y in facets[x]['facets']:
for z in facets[x]['facets'][y]:
key = z.title()
if key not in exclusions:
if key in ["Rectum", "Colon"]:
sapien_counts["Colorectal"]['cases'] += facets[x]['facets'][y][z]
else:
if z == 'HEADNECK':
key = 'Head and Neck'
sapien_counts[key] = {'site': key, 'cases': facets[x]['facets'][y][z], 'fileCount': 0}
for collection in collex:
loc = collection['location']
if collection['location'] in changes:
loc = changes[collection['location']]
if loc not in sapien_counts:
sapien_counts[loc] = 0
sapien_counts[loc] += collection['subject_count']


return render(request, 'idc/landing.html', {'request': request, 'case_counts': [sapien_counts[x] for x in sapien_counts] })
return render(request, 'idc/landing.html', {'request': request, 'case_counts': [{'site': x, 'cases':sapien_counts[x], 'fileCount':0 } for x in sapien_counts.keys()] })

# Displays the privacy policy
@never_cache
Expand Down
6 changes: 5 additions & 1 deletion shell/database-refresh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ else
mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD -e "DROP DATABASE IF EXISTS $DATABASE_NAME"
mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE $DATABASE_NAME"
echo "Database $DATABASE_NAME dropped and re-created."
( "/home/vagrant/www/shell/database-setup.sh" )
if [ -n $1 ] && [ "$1" == "no_seed" ]; then
/home/vagrant/www/shell/database-setup.sh "$@"
else
( "/home/vagrant/www/shell/database-setup.sh" )
fi
fi
29 changes: 17 additions & 12 deletions shell/database-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,26 @@ mysql -u$MYSQL_ROOT_USER -h $MYSQL_DB_HOST -p$MYSQL_ROOT_PASSWORD -D$DATABASE_NA
# Load your SQL table file
# Looks for metadata_featdef_tables.sql, if this isn't found, it downloads a file from GCS and saves it as
# metadata_tables.sql for future use
if [ ! -f ${HOMEROOT}/scripts/${METADATA_SQL_FILE} ]; then
# Sometimes CircleCI loses its authentication, re-auth with the dev key if we're on circleCI...
if [ -n "$CI" ]; then
sudo gcloud auth activate-service-account --key-file ${HOMEROOT}/deployment.key.json
# otherwise just use privatekey.json
else
sudo gcloud auth activate-service-account --key-file ${HOMEROOT}/${SECURE_LOCAL_PATH}/${GOOGLE_APPLICATION_CREDENTIALS}
sudo gcloud config set project "${GCLOUD_PROJECT_ID}"
if [ -n $1 ] && [ "$1" == "no_seed" ]; then
echo "SQL Table file will not be applied."
else
if [ ! -f ${HOMEROOT}/scripts/${METADATA_SQL_FILE} ]; then
# Sometimes CircleCI loses its authentication, re-auth with the dev key if we're on circleCI...
if [ -n "$CI" ]; then
sudo gcloud auth activate-service-account --key-file ${HOMEROOT}/deployment.key.json
# otherwise just use privatekey.json
else
sudo gcloud auth activate-service-account --key-file ${HOMEROOT}/${SECURE_LOCAL_PATH}/${GOOGLE_APPLICATION_CREDENTIALS}
sudo gcloud config set project "${GCLOUD_PROJECT_ID}"
fi
echo "Downloading SQL Table File..."
sudo gsutil cp "gs://${GCLOUD_BUCKET_DEV_SQL}/${METADATA_SQL_FILE}" ${HOMEROOT}/scripts/${METADATA_SQL_FILE}
fi
echo "Downloading SQL Table File..."
sudo gsutil cp "gs://${GCLOUD_BUCKET_DEV_SQL}/${METADATA_SQL_FILE}" ${HOMEROOT}/scripts/${METADATA_SQL_FILE}
echo "Applying SQL Table File... (may take a while)"
mysql -u$MYSQL_ROOT_USER -h $MYSQL_DB_HOST -p$MYSQL_ROOT_PASSWORD -D$DATABASE_NAME < ${HOMEROOT}/scripts/${METADATA_SQL_FILE}
fi
echo "Applying SQL Table File... (may take a while)"
mysql -u$MYSQL_ROOT_USER -h $MYSQL_DB_HOST -p$MYSQL_ROOT_PASSWORD -D$DATABASE_NAME < ${HOMEROOT}/scripts/${METADATA_SQL_FILE}
echo "Adding Django site IDs..."
python3 ${HOMEROOT}/scripts/add_site_ids.py
Expand Down
15 changes: 13 additions & 2 deletions static/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion static/js/sapien.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ require([
Uterus: 'rgb(245, 97, 154)',
};

let data = case_counts;
let data = case_counts.sort(function(a,b){
let aSite = a['site'].toLowerCase();
let bSite = b['site'].toLowerCase();
if( aSite == bSite) {
return 0;
}
if(aSite < bSite) {
return -1;
}
return 1;
});

function clickHandler() {
console.debug("HANDLE IT");
Expand Down
2 changes: 1 addition & 1 deletion templates/accounts/account/password_reset_done.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
</div>
<div class="col-lg-4"></div>
</div>
</div>
</div>
{% endblock %}
15 changes: 12 additions & 3 deletions templates/idc/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@
{% block content %}
<div class="landing-content-div container-fluid">
<div class="features row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="modality">
ljdjg;dlskfj;sgldk
<div class="col-lg-6 col-md-6 col-sm-6 modality">
<div class="modality panel panel-default">
<div class="panel-heading"><h3>RADIOLOGY</h3></div>
<div class="panel-body" style="min-height: 325px;">

</div>
<div class="panel-body">
<div class="panel-heading"><h4>Top Imaging Modalities</h4></div>
<div class="col-sm-4"><p>Computer Tomography</p></div>
<div class="col-sm-4">Magnetic Resonance</div>
<div class="col-sm-4">PET</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
Expand Down

0 comments on commit 69a291b

Please sign in to comment.