Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes bug 852466 - Added release channel filter in search report/list…

… services.
  • Loading branch information...
commit 1b7048ac8fb63a07ac506dd0adad332b88e78a5e 1 parent 41b7668
Adrian Gaudebert AdrianGaudebert authored
8 docs/middleware.rst
View
@@ -273,6 +273,8 @@ Optional parameters
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| reasons | String or list of strings | None | Restricts search to crashes caused by this reason. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
+| release_channels | String or list of strings | None | Restricts search to crashes with these release channels. |
++------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build\_ids | Integer or list of integers | None | Restricts search to crashes that happened on a product with this build ID. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build\_from | Integer or list of integers | None | Restricts search to crashes with a build id greater than this. |
@@ -498,6 +500,8 @@ Optional parameters
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| reasons | String or list of strings | None | Restricts search to crashes caused by this reason. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
+| release_channels | String or list of strings | None | Restricts search to crashes with these release channels. |
++------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build\_ids | Integer or list of integers | None | Restricts search to crashes that happened on a product with this build ID. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build\_from | Integer or list of integers | None | Restricts search to crashes with a build id greater than this. |
@@ -1384,6 +1388,8 @@ Optional parameters
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| reasons | String or list of strings | None | Restricts search to crashes caused by this reason. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
+| release_channels | String or list of strings | None | Restricts search to crashes with these release channels. |
++------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build_ids | Integer or list of integers | None | Restricts search to crashes that happened on a product with this build ID. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build\_from | Integer or list of integers | None | Restricts search to crashes with a build id greater than this. |
@@ -1641,6 +1647,8 @@ Optional parameters
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| reasons | String or list of strings | None | Restricts search to crashes caused by this reason. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
+| release_channels | String or list of strings | None | Restricts search to crashes with these release channels. |
++------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build\_ids | Integer or list of integers | None | Restricts search to crashes that happened on a product with this build ID. |
+------------------------+-------------------------------+----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| build\_from | Integer or list of integers | None | Restricts search to crashes with a build id greater than this. |
7 socorro/external/elasticsearch/base.py
View
@@ -176,6 +176,13 @@ def build_query_from_params(params, config):
filters["and"].append(
ElasticSearchBase.build_terms_query("reason",
[x.lower() for x in params["reasons"]]))
+ if params["release_channels"]:
+ filters["and"].append(
+ ElasticSearchBase.build_terms_query(
+ "release_channel",
+ [x.lower() for x in params["release_channels"]]
+ )
+ )
filters["and"].append({
"range": {
10 socorro/external/elasticsearch/search.py
View
@@ -41,6 +41,16 @@ def get(self, **kwargs):
Optional arguments: see SearchCommon.get_parameters()
"""
+ # change aliases from the web to the implementation's need
+ if "for" in kwargs and "terms" not in kwargs:
+ kwargs["terms"] = kwargs.get("for")
+ if "from" in kwargs and "from_date" not in kwargs:
+ kwargs["from_date"] = kwargs.get("from")
+ if "to" in kwargs and "to_date" not in kwargs:
+ kwargs["to_date"] = kwargs.get("to")
+ if "in" in kwargs and "fields" not in kwargs:
+ kwargs["fields"] = kwargs.get("in")
+
params = search_common.get_parameters(kwargs)
# Get information about the versions
13 socorro/external/postgresql/base.py
View
@@ -257,6 +257,19 @@ def build_reports_sql_where(params, sql_params, config):
sql_params = add_param_to_dict(sql_params, "reason",
params["reasons"])
+ ## Adding release channels to where clause
+ if params["release_channels"]:
+ channels_list = [
+ "r.release_channel=%%(release_channel%s)s" % x
+ for x in range(len(params["release_channels"]))
+ ]
+ sql_where.append("(%s)" % " OR ".join(channels_list))
+ sql_params = add_param_to_dict(
+ sql_params,
+ "release_channel",
+ params["release_channels"]
+ )
+
## Adding report type to where clause
if params["report_type"] == "crash":
sql_where.append("r.hangid IS NULL")
3  socorro/lib/search_common.py
View
@@ -54,6 +54,8 @@ def get_parameters(kwargs):
Default is all.
reasons -- Restrict search to crashes caused by this reason.
Default is all.
+ release_channels -- Restrict search to crashes in this release channels.
+ Default is all.
report_type -- Retrict to a type of report.
Can be any, crash or hang.
Default is any.
@@ -91,6 +93,7 @@ def get_parameters(kwargs):
("versions", None, ["list", "str"]),
("os", None, ["list", "str"]),
("reasons", None, ["list", "str"]),
+ ("release_channels", None, ["list", "str"]),
("build_ids", None, ["list", "str"]),
("build_from", lastweek, "datetime"),
("build_to", now, "datetime"),
22 socorro/unittest/external/postgresql/test_search.py
View
@@ -140,7 +140,7 @@ def setUp(self):
'Linux',
null,
'plugin',
- 'Release'
+ 'Nightly'
),
(
8,
@@ -168,7 +168,7 @@ def setUp(self):
'Linux',
null,
'browser',
- 'Release'
+ 'Nightly'
),
(
10,
@@ -401,3 +401,21 @@ def test_get(self):
res = search.get(**params)
self.assertEqual(res['total'], 2)
self.assertEqual(res, res_expected)
+
+ # Test 9: release channels
+ params = {
+ 'release_channels': ['Nightly']
+ }
+ res = search.get(**params)
+ self.assertEqual(res['total'], 2)
+
+ hits = res['hits'][0]
+ self.assertEqual(hits['signature'], 'js::functions::call::hello_world')
+ hits = res['hits'][1]
+ self.assertEqual(hits['signature'], 'sig2')
+
+ params = {
+ 'release_channels': ['Nightly', 'Release']
+ }
+ res = search.get(**params)
+ self.assertEqual(res['total'], 5)
1  socorro/unittest/lib/test_search_common.py
View
@@ -40,6 +40,7 @@ def test_get_parameters(self):
"to_date": "",
"versions": "",
"reasons": "",
+ "release_channels": "",
"os": "",
"search_mode": "",
"build_ids": "",
Please sign in to comment.
Something went wrong with that request. Please try again.