Skip to content
Browse files

Merge pull request #134 from rhelmer/2.3.2

2.3.2
  • Loading branch information...
2 parents ebaf6fe + 714d9c4 commit f4e8013763425799f32a85719d28a8269e79bbb7 @rhelmer rhelmer committed Nov 3, 2011
View
2 socorro/cron/ftpscraper.py
@@ -205,7 +205,7 @@ def scrapeNightlies(config, cursor, product_name, urllib=urllib2, date=None):
try:
day = date.strftime('%d')
- dir_prefix = '%s-%s-%s' % (date.year, date.month, day)
+ dir_prefix = '%s-%s-%s' % (date.year, month, day)
nightlies = getLinks(nightly_url, startswith=dir_prefix,
urllib=urllib)
for nightly in nightlies:
View
120 socorro/search/postgresql.py
@@ -2,8 +2,9 @@
from datetime import timedelta, datetime
-import socorro.lib.util as util
import socorro.database.database as db
+import socorro.lib.util as util
+import socorro.services.versions_info as vi
import searchapi as sapi
logger = logging.getLogger("webapi")
@@ -193,11 +194,15 @@ def search(self, types, **kwargs):
## Adding versions to where clause
if versions != "_all" and len(versions):
- contains_beta = False
+
+ # Get information about the versions
+ versions_service = vi.VersionsInfo(self.context)
+ fakeparams = {}
+ fakeparams["version"] = versions_list
+ versions_info = versions_service.versions_info(fakeparams)
if type(versions) is list:
versions_where = []
- versions_info = self.get_versions_info(cur, versions)
for x in xrange(0, len(versions), 2):
version_where = []
@@ -211,37 +216,27 @@ def search(self, types, **kwargs):
else:
version_info = None
- if version_info and version_info["which_table"] == "new":
- if "b" in version_info["version_string"]:
- # it's a beta
- version_where.append(str(x + 1).join((
- "product_versions.version_string=%(version",
- ")s")))
- version_where.append("""r.version = product_versions.release_version
- AND r.release_channel ILIKE 'beta'
- AND product_versions.build_type = 'beta'
- AND EXISTS ( SELECT 1 FROM product_version_builds
- WHERE product_versions.product_version_id = product_version_builds.product_version_id
- AND build_numeric(r.build) = product_version_builds.build_id )
- """)
- contains_beta = True
+ if version_info and version_info["release_channel"]:
+ if version_info["release_channel"] in ("Beta", "Aurora", "Nightly"):
+ # Use major_version instead of full version
+ params["version%s" % (x + 1)] = version_info["major_version"]
+ # Restrict by release_channel
+ version_where.append("r.release_channel ILIKE '%s'" % version_info["release_channel"])
+ if version_info["release_channel"] == "Beta":
+ # Restrict to a list of build_id
+ version_where.append("r.build IN ('%s')" % "', '".join([str(bid) for bid in version_info["build_id"]]))
+
else:
# it's a release
- version_where.append(str(x + 1).join((
- "r.version=%(version", ")s")))
version_where.append("r.release_channel NOT IN ('nightly', 'aurora', 'beta')")
- else:
- version_where.append(str(x + 1).join((
- "r.version=%(version", ")s")))
+ version_where.append(str(x + 1).join((
+ "r.version=%(version", ")s")))
versions_where.append("(%s)" % " AND ".join(version_where))
- sql_where.append("".join(("(",
- " OR ".join(versions_where),
- ")")))
+ sql_where.append("(%s)" % " OR ".join(versions_where))
else:
- versions_info = self.get_versions_info(cur, (products, versions))
# Original product:value
key = ":".join((products, versions))
if key in versions_info:
@@ -250,26 +245,19 @@ def search(self, types, **kwargs):
version_info = None
if version_info and version_info["which_table"] == "new":
- if "b" in version_info["version_string"]:
- # it's a beta
- sql_where.append("product_versions.version_string=%(version)s")
- sql_where.append("""r.version = product_versions.release_version
- AND r.release_channel ILIKE 'beta'
- AND product_versions.build_type = 'beta'
- AND EXISTS ( SELECT 1 FROM product_version_builds
- WHERE product_versions.product_version_id = product_version_builds.product_version_id
- AND build_numeric(r.build) = product_version_builds.build_id )
- """)
- contains_beta = True
+ if version_info["release_channel"] in ("Beta", "Aurora", "Nightly"):
+ # Use major_version instead of full version
+ params["version"] = version_info["major_version"]
+ # Restrict by release_channel
+ version_where.append("r.release_channel ILIKE '%s'" % version_info["release_channel"])
+ # Restrict to a list of build_id
+ version_where.append("r.build IN (%s)" % ", ".join([str(bid) for bid in version_info["build_id"]]))
+
else:
# it's a release
- sql_where.append("r.version=%(version)s")
- sql_where.append("r.release_channel NOT IN ('nightly', 'aurora', 'beta')")
- else:
- sql_where.append("r.version=%(version)s")
+ version_where.append("r.release_channel NOT IN ('nightly', 'aurora', 'beta')")
- if contains_beta:
- sql_from.append("product_versions ON r.version = product_versions.release_version AND r.product = product_versions.product_name")
+ sql_where.append("r.version=%(version)s")
## Adding build id to where clause
if build_id:
@@ -440,52 +428,6 @@ def generate_sql_group(self, report_process):
return ", ".join(sql_group)
- def get_versions_info(self, cur, product_version_list):
- """
-
- """
- if not product_version_list:
- return None
-
- versions = []
- products = []
- for x in xrange(0, len(product_version_list), 2):
- products.append(product_version_list[x])
- versions.append(product_version_list[x + 1])
-
- params = {}
- params = PostgresAPI.dispatch_params(params, "product", products)
- params = PostgresAPI.dispatch_params(params, "version", versions)
-
- where = []
- for i in xrange(len(products)):
- index = str(i)
- where.append(index.join(("(pi.product_name = %(product",
- ")s AND pi.version_string = %(version",
- ")s)")))
-
- sql = """/* socorro.search.postgresql.PostgresAPI.get_product_info */
- SELECT pi.version_string, which_table, major_version, pi.product_name
- FROM product_info pi
- JOIN product_versions pv ON
- (pv.product_version_id = pi.product_version_id)
- WHERE %s
- """ % " OR ".join(where)
-
- try:
- results = db.execute(cur, sql, params)
- except Exception:
- results = []
- util.reportExceptionAndContinue(logger)
-
- res = {}
- for line in results:
- row = dict(zip(("version_string", "which_table",
- "major_version", "product_name"), line))
- res[":".join((row["product_name"], row["version_string"]))] = row
-
- return res
-
@staticmethod
def dispatch_params(params, key, value):
"""
View
72 socorro/services/versions_info.py
@@ -2,7 +2,6 @@
import socorro.lib.util as util
import socorro.database.database as db
-import socorro.search.postgresql as pg
import socorro.webapi.webapiService as webapi
logger = logging.getLogger("webapi")
@@ -60,7 +59,7 @@ def versions_info(self, params):
return None
products_list = []
- (versions_list, products_list) = pg.PostgresAPI.parse_versions(
+ (versions_list, products_list) = VersionsInfo.parse_versions(
params["version"],
products_list)
@@ -74,8 +73,8 @@ def versions_info(self, params):
versions.append(versions_list[x + 1])
params = {}
- params = pg.PostgresAPI.dispatch_params(params, "product", products)
- params = pg.PostgresAPI.dispatch_params(params, "version", versions)
+ params = VersionsInfo.dispatch_params(params, "product", products)
+ params = VersionsInfo.dispatch_params(params, "version", versions)
where = []
for i in xrange(len(products)):
@@ -85,8 +84,8 @@ def versions_info(self, params):
")s)")))
sql = """/* socorro.middleware.postgresql.util.Util.versions_info */
- SELECT pi.version_string, pi.product_name, which_table, major_version,
- pv.build_type, pvb.build_id
+ SELECT pi.version_string, pi.product_name, which_table,
+ pv.release_version, pv.build_type, pvb.build_id
FROM product_info pi
LEFT JOIN product_versions pv ON
(pv.product_version_id = pi.product_version_id)
@@ -147,3 +146,64 @@ def _parse_query_string(self, query_string):
params[i] = params[i].split(terms_sep)
return params
+
+ # ---
+ # Those methods are a dup from socorro.search.postgresql and will be moved
+ # by the middleware reorg (bug 681112).
+ # This is ugly but will be solved soon.
+ # ---
+
+ @staticmethod
+ def dispatch_params(params, key, value):
+ """
+ Dispatch a parameter or a list of parameters into the params array.
+
+ """
+ if type(value) is not list:
+ params[key] = value
+ else:
+ for i in xrange(len(value)):
+ params[key+str(i)] = value[i]
+ return params
+
+ @staticmethod
+ def append_to_var(value, array):
+ """
+ Append a value to a list or array.
+ If array is not a list, create a new one containing array
+ and value.
+
+ """
+ if type(array) is list:
+ array.append(value)
+ elif array == "_all" or array == None:
+ array = value
+ elif array != value:
+ array = [array, value]
+ return array
+
+ @staticmethod
+ def parse_versions(versions_list, products):
+ """
+ Parses the versions, separating by ":" and returning versions
+ and products.
+
+ """
+ versions = []
+ if type(versions_list) is list:
+ for v in versions_list:
+ if v.find(":") > -1:
+ pv = v.split(":")
+ versions = VersionsInfo.append_to_var(pv[0], versions)
+ versions = VersionsInfo.append_to_var(pv[1], versions)
+ else:
+ products = VersionsInfo.append_to_var(v, products)
+ elif versions_list != "_all":
+ if versions_list.find(":") > -1:
+ pv = versions_list.split(":")
+ versions = VersionsInfo.append_to_var(pv[0], versions)
+ versions = VersionsInfo.append_to_var(pv[1], versions)
+ else:
+ products = VersionsInfo.append_to_var(versions_list, products)
+
+ return (versions, products)
View
5 webapp-php/application/libraries/MY_SearchReportHelper.php
@@ -93,6 +93,11 @@ public function normalizeParams( &$params ){
* @param array An array of $_GET parameters
*/
public function normalizeDateUnitAndValue(&$params){
+
+ if(isset($params['range_value'])) {
+ $params['range_value'] = (int)$params['range_value'];
+ }
+
$range_defaults = Kohana::config('application.query_range_defaults');
$range_key = (isset($params['admin']) && $params['admin']) ? 'admin' : 'user';
View
17 webapp-php/application/models/common.php 100644 → 100755
@@ -312,9 +312,14 @@ public function _buildCriteriaFromSearchParams($params) {
$version_string = $result[0]->version_string;
$which_table = $result[0]->which_table;
$major_version = $result[0]->major_version;
+
if (strpos($version_string, 'b')) {
$channel = 'beta';
$reports_version = $major_version;
+ } else if (strpos($version_string, 'a1')) {
+ $channel = 'nightly';
+ } else if (strpos($version_string, 'a2')) {
+ $channel = 'aurora';
} else {
$channel = 'release';
}
@@ -332,12 +337,22 @@ public function _buildCriteriaFromSearchParams($params) {
" AND reports.release_channel ILIKE 'beta'" .
" AND product_versions.build_type = 'Beta'" .
" AND EXISTS ( SELECT 1 FROM product_version_builds WHERE product_versions.product_version_id = product_version_builds.product_version_id AND build_numeric(reports.build) = product_version_builds.build_id ))";
- } else if ($channel = 'release') {
+ } else if ($channel == 'release') {
$or[] =
"(reports.product = " . $this->db->escape($product) .
"AND reports.version = " . $this->db->escape($reports_version) .
"AND product_versions.build_type = 'Release'" .
"AND reports.release_channel NOT IN ('nightly', 'aurora', 'beta'))";
+ } else if ($channel == 'aurora') {
+ $or[] =
+ "(reports.product = " . $this->db->escape($product) .
+ "AND reports.version = " . $this->db->escape($reports_version) .
+ "AND product_versions.build_type = 'Aurora')";
+ } else if ($channel == 'nightly') {
+ $or[] =
+ "(reports.product = " . $this->db->escape($product) .
+ "AND reports.version = " . $this->db->escape($reports_version) .
+ "AND product_versions.build_type = 'Nightly')";
}
} else {

0 comments on commit f4e8013

Please sign in to comment.
Something went wrong with that request. Please try again.