Skip to content

Commit

Permalink
Projection search form logging done, but some future work needed for …
Browse files Browse the repository at this point in the history
…label after redesign
  • Loading branch information
jorvis committed Sep 27, 2023
1 parent 0300602 commit 2b9e705
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/gear/userhistory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import geardb
import re
import sys
import urllib

class UserHistory:
Expand Down Expand Up @@ -28,6 +29,7 @@ def add_record(self, user_id=None, entry_category=None, label=None, **kwargs):
'projection_run' -> patterns, algo, gene_cart, multi, layout_share_id
"""
print("DEBUG: UserHistory.add_record called, entry_category:{0}".format(entry_category), file=sys.stderr)
match entry_category:
case 'dataset_search':
if 'search_terms' in kwargs:
Expand Down Expand Up @@ -84,11 +86,21 @@ def add_record(self, user_id=None, entry_category=None, label=None, **kwargs):
url += "&g={0}&multi=1&gsem=1".format(gene_string)

case 'projection_run':
# looks like: https://nemoanalytics.org/p?p=p&multi=0&l=4e8f6c00&c=00be4b21&algo=pca
# looks like: https://nemoanalytics.org/p?p=p&multi=0&l=4e8f6c00& c=00be4b21 &algo=pca
if 'layout_share_id' in kwargs:
url = "/p?p=p&l={0}".format(kwargs['layout_share_id'])
else:
raise Exception("ERROR: If recording a layout_added category, 'layout_share_id' must be passsed")
raise Exception("ERROR: If recording a projection_run category, 'layout_share_id' must be passsed")

if 'multi' in kwargs:
url += "&multi={0}".format(kwargs['multi'])
else:
raise Exception("ERROR: If recording a projection_run category, 'multi' must be passsed")

if 'gene_cart' in kwargs:
url += "&c={0}".format(kwargs['gene_cart'])
else:
raise Exception("ERROR: If recording a projection_run category, 'gene_cart' must be passsed")

case _ :
raise Exception("ERROR: Invalid entry_category when calling UserHistory.add_record()")
Expand Down
19 changes: 19 additions & 0 deletions www/js/projection.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,25 @@ $("#projection_search_form").submit((event) => {
dataset_collection_panel.datasets.map((dataset) => {
run_projection(dataset, projection_source, projection_algorithm, gctype, selected_projections, first_thing);
});

// TODO, build the 'label' and add it here.
const history_label = 'Projection of ' + layout_id + ' into ' + projection_source + ' for datasets in profile <profilename>'

$.ajax({
type: "POST",
url: "./cgi/add_to_user_history.cgi",
async: false,
data: {
'session_id': session_id,
'entry_category': 'projection_run',
'label': history_label,
'layout_share_id': layout_id,
'gene_cart': projection_source,
'multi': multipattern ? 1 : 0
},
dataType: "json"
})

return false; // keeps the page from not refreshing
}

Expand Down

0 comments on commit 2b9e705

Please sign in to comment.