Nschaaf has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/338763 )

Change subject: Fix url param escaping & add no results message
......................................................................

Fix url param escaping & add no results message

Bug: T156477
Change-Id: I1db5dfc6b5439cb1d2c6e4bd2d965815f7ddd4f4
---
M recommendation/web/gapfinder.py
M recommendation/web/static/gf-input.tag
M recommendation/web/static/i18n/en.json
M recommendation/web/static/i18n/qqq.json
M setup.py
5 files changed, 15 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/research/recommendation-api 
refs/changes/63/338763/1

diff --git a/recommendation/web/gapfinder.py b/recommendation/web/gapfinder.py
index 162b28d..f73e468 100644
--- a/recommendation/web/gapfinder.py
+++ b/recommendation/web/gapfinder.py
@@ -20,11 +20,11 @@
         'index.html',
         language_pairs=json.dumps(pairs),
         
language_to_domain_mapping=json.dumps(language_pairs.get_language_to_domain_mapping()),
-        s=s,
-        t=t,
-        seed=seed,
-        search=search,
-        rank_method=rank_method,
+        s=json.dumps(s),
+        t=json.dumps(t),
+        seed=json.dumps(seed),
+        search=json.dumps(search),
+        rank_method=json.dumps(rank_method),
         event_logger_url=configuration.get_config_value('endpoints', 
'event_logger'),
         default_search=configuration.get_config_value('gapfinder', 
'default_search')
     )
diff --git a/recommendation/web/static/gf-input.tag 
b/recommendation/web/static/gf-input.tag
index 98224dc..bddd7ca 100644
--- a/recommendation/web/static/gf-input.tag
+++ b/recommendation/web/static/gf-input.tag
@@ -87,9 +87,16 @@
                 self.fetching = false;
                 self.update();
             }).done(function (data) {
+                if (!data || !data.length) {
+                    self.error = true;
+                    self.error_msg = 'status-no-results';
+                    self.update();
+                    return;
+                }
                 if (data.error) {
                     self.error = true;
                     self.error_msg = data.error;
+                    self.update();
                     return;
                 }
 
diff --git a/recommendation/web/static/i18n/en.json 
b/recommendation/web/static/i18n/en.json
index a8bcd53..254b699 100644
--- a/recommendation/web/static/i18n/en.json
+++ b/recommendation/web/static/i18n/en.json
@@ -17,6 +17,7 @@
        "status-preparing": "Preparing article recommendations...",
        "status-must-be-different": "Source and target languages must be 
different",
        "status-invalid-language": "Invalid source or target language",
+       "status-no-results": "No recommendations were available for the 
specified parameters",
        "article-pageviews": "$1 recent {{PLURAL:$1|view|views}}",
        "article-flag": "Flag this article...",
        "article-flag-not-interesting": "Not interesting",
diff --git a/recommendation/web/static/i18n/qqq.json 
b/recommendation/web/static/i18n/qqq.json
index a044dab..4805342 100644
--- a/recommendation/web/static/i18n/qqq.json
+++ b/recommendation/web/static/i18n/qqq.json
@@ -21,6 +21,7 @@
        "status-preparing": "Status message that indicates the list of 
recommendations are being prepared",
        "status-must-be-different": "Message indicating the source and target 
languages must be different",
        "status-invalid-language": "Message indicating that either the source 
or target language are invalid",
+       "status-no-results": "Message indicating that there were no results",
        "article-pageviews": "Message indicating the number of recent pageviews 
an article has.\n\nBegin the message with an upper case character if your 
language capitalizes the beginnings of sentences.",
        "article-flag": "Text describing the option to flag an article in one 
of many (currently 2) ways",
        "article-flag-not-interesting": "Text describing the article as not 
being interesting to the user",
diff --git a/setup.py b/setup.py
index 37e8099..eeaa34e 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@
 
 setup(
     name='recommendation',
-    version='0.2.0',
+    version='0.2.2',
     url='https://github.com/wikimedia/research-recommendation-api',
     license='Apache Software License',
     maintainer='Wikimedia Research',

-- 
To view, visit https://gerrit.wikimedia.org/r/338763
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1db5dfc6b5439cb1d2c6e4bd2d965815f7ddd4f4
Gerrit-PatchSet: 1
Gerrit-Project: research/recommendation-api
Gerrit-Branch: master
Gerrit-Owner: Nschaaf <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to