Repository: getredash/redash

Issue:
Fix Yandex Metrica name
Should be Yandex Metrica. Need to apply a fix, but keep the type name with a `k` to avoid breaking existing deployments.


Discussion:
FWIW, it seems it has been rebranded for the global market, e.g. see https://metrika.yandex.ru/promo.
The API URL is also specified as [`api-metrica.yandex.com`](https://tech.yandex.com/metrika/doc/api2/api_v1/examples-docpage/) (instead of our `api-metrika.yandex.ru`) now, I think we should update that as well.

Resolving patch:
diff --git a/redash/query_runner/yandex_metrika.py b/redash/query_runner/yandex_metrica.py
similarity index 87%
rename from redash/query_runner/yandex_metrika.py
rename to redash/query_runner/yandex_metrica.py
--- a/redash/query_runner/yandex_metrika.py
+++ b/redash/query_runner/yandex_metrica.py
@@ -59,18 +59,19 @@ def parse_ym_response(response):
     return {'columns': columns, 'rows': rows}
 
 
-class YandexMetrika(BaseSQLQueryRunner):
+class YandexMetrica(BaseSQLQueryRunner):
     @classmethod
     def annotate_query(cls):
         return False
 
     @classmethod
     def type(cls):
+        # This is written with a "k" for backward-compatibility. See #2874.
         return "yandex_metrika"
 
     @classmethod
     def name(cls):
-        return "Yandex Metrika"
+        return "Yandex Metrica"
 
     @classmethod
     def configuration_schema(cls):
@@ -86,9 +87,9 @@ def configuration_schema(cls):
         }
 
     def __init__(self, configuration):
-        super(YandexMetrika, self).__init__(configuration)
+        super(YandexMetrica, self).__init__(configuration)
         self.syntax = 'yaml'
-        self.host = 'https://api-metrika.yandex.ru'
+        self.host = 'https://api-metrica.yandex.com'
         self.list_path = 'counters'
 
     def _get_tables(self, schema):
@@ -118,7 +119,7 @@ def _send_query(self, path='stat/v1/data', **kwargs):
         return r.json()
 
     def run_query(self, query, user):
-        logger.debug("Metrika is about to execute query: %s", query)
+        logger.debug("Metrica is about to execute query: %s", query)
         data = None
         query = query.strip()
         if query == "":
@@ -147,20 +148,21 @@ def run_query(self, query, user):
         return data, error
 
 
-class YandexAppMetrika(YandexMetrika):
+class YandexAppMetrica(YandexMetrica):
     @classmethod
     def type(cls):
+        # This is written with a "k" for backward-compatibility. See #2874.
         return "yandex_appmetrika"
 
     @classmethod
     def name(cls):
-        return "Yandex AppMetrika"
+        return "Yandex AppMetrica"
 
     def __init__(self, configuration):
-        super(YandexAppMetrika, self).__init__(configuration)
-        self.host = 'https://api.appmetrica.yandex.ru'
+        super(YandexAppMetrica, self).__init__(configuration)
+        self.host = 'https://api.appmetrica.yandex.com'
         self.list_path = 'applications'
 
 
-register(YandexMetrika)
-register(YandexAppMetrika)
+register(YandexMetrica)
+register(YandexAppMetrica)
diff --git a/redash/settings/__init__.py b/redash/settings/__init__.py
--- a/redash/settings/__init__.py
+++ b/redash/settings/__init__.py
@@ -169,7 +169,7 @@ def all_settings():
     'redash.query_runner.impala_ds',
     'redash.query_runner.vertica',
     'redash.query_runner.clickhouse',
-    'redash.query_runner.yandex_metrika',
+    'redash.query_runner.yandex_metrica',
     'redash.query_runner.treasuredata',
     'redash.query_runner.sqlite',
     'redash.query_runner.dynamodb_sql',


Test patch: