Include closed bugs in queries with a maxDate

This commit is contained in:
Panagiotis Astithas 2019-06-03 18:59:44 -07:00
Родитель 7aea941872
Коммит dca779476d
2 изменённых файлов: 28 добавлений и 10 удалений

36
bugs.js
Просмотреть файл

@ -53,25 +53,30 @@ function formatDateForAPIQueries(date) {
}
/**
* Returns Bugzilla bugs created after 2018-01-01.
* @param {*} website
* @param {*} bugzillaKey
* Returns Bugzilla bugs created after minDate if specified, 2018-01-01 otherwise.
* @param {String} website
* @param {String} bugzillaKey
* @param {Date} minDate
* @param {Date} maxDate
*/
const getBugzilla = async (website, bugzillaKey, minDate, maxDate) => {
const minDateQuery = minDate ? formatDateForAPIQueries(minDate) : "2018";
const maxDateQuery = maxDate ? formatDateForAPIQueries(maxDate) : "";
const maxDateQueryFragment = maxDate ? `&f4=creation_ts&o4=lessthaneq&v4=${formatDateForAPIQueries(maxDate)}` : "";
const query = `https://bugzilla.mozilla.org/buglist.cgi?f1=OP&bug_file_loc_type=allwordssubstr&o3=greaterthaneq&list_id=14636479&v3=${minDateQuery}&resolution=---&bug_file_loc=${website}&query_format=advanced&f3=creation_ts&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&product=Core&product=Fenix&product=Firefox%20for%20Android&product=Firefox%20for%20Echo%20Show&product=Firefox%20for%20FireTV&product=Firefox%20for%20iOS&product=GeckoView&product=Web%20Compatibility&keywords_type=nowords&keywords=meta%2C%20&status_whiteboard_type=notregexp&status_whiteboard=sci%5C-exclude${maxDateQueryFragment}`;
const apiQuery = `https://bugzilla.mozilla.org/rest/bug?include_fields=id,summary,status&bug_file_loc=${website}&bug_file_loc_type=allwordssubstr&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&f1=OP&f3=creation_ts&keywords=meta%2C%20&keywords_type=nowords&o3=greaterthaneq&product=Core&product=Fenix&product=Firefox%20for%20Android&product=Firefox%20for%20Echo%20Show&product=Firefox%20for%20FireTV&product=Firefox%20for%20iOS&product=GeckoView&product=Web%20Compatibility&resolution=---&status_whiteboard=sci%5C-exclude&status_whiteboard_type=notregexp&v3=${minDateQuery}&api_key=${bugzillaKey}${maxDateQueryFragment}`;
const promiseFn = () => fetch(apiQuery);
const openQuery = `https://bugzilla.mozilla.org/buglist.cgi?f1=OP&bug_file_loc_type=allwordssubstr&o3=greaterthaneq&list_id=14636479&v3=${minDateQuery}&resolution=---&bug_file_loc=${website}&query_format=advanced&f3=creation_ts&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&product=Core&product=Fenix&product=Firefox%20for%20Android&product=Firefox%20for%20Echo%20Show&product=Firefox%20for%20FireTV&product=Firefox%20for%20iOS&product=GeckoView&product=Web%20Compatibility&keywords_type=nowords&keywords=meta%2C%20&status_whiteboard_type=notregexp&status_whiteboard=sci%5C-exclude${maxDateQueryFragment}`;
// const resolvedQuery = `https://bugzilla.mozilla.org/buglist.cgi?keywords=meta%2C%20&keywords_type=nowords&list_id=14745792&status_whiteboard_type=notregexp&bug_file_loc=google.com&chfield=bug_status&chfieldfrom=${maxDateQuery}&o4=lessthaneq&chfieldvalue=RESOLVED&status_whiteboard=sci%5C-exclude&v4=${maxDateQuery}&f1=OP&o3=greaterthaneq&bug_file_loc_type=allwordssubstr&v3=${minDateQuery}&f4=creation_ts&query_format=advanced&f3=creation_ts&product=Core&product=Fenix&product=Firefox%20for%20Android&product=Firefox%20for%20Echo%20Show&product=Firefox%20for%20FireTV&product=Firefox%20for%20iOS&product=GeckoView&product=Web%20Compatibility`;
const openApiQuery = `https://bugzilla.mozilla.org/rest/bug?include_fields=id,summary,status&bug_file_loc=${website}&bug_file_loc_type=allwordssubstr&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&f1=OP&f3=creation_ts&keywords=meta%2C%20&keywords_type=nowords&o3=greaterthaneq&product=Core&product=Fenix&product=Firefox%20for%20Android&product=Firefox%20for%20Echo%20Show&product=Firefox%20for%20FireTV&product=Firefox%20for%20iOS&product=GeckoView&product=Web%20Compatibility&resolution=---&status_whiteboard=sci%5C-exclude&status_whiteboard_type=notregexp&v3=${minDateQuery}&api_key=${bugzillaKey}${maxDateQueryFragment}`;
const resolvedApiQuery = `https://bugzilla.mozilla.org/rest/bug?include_fields=id,summary,status&bug_file_loc=${website}&bug_file_loc_type=allwordssubstr&chfield=bug_status&chfieldfrom=${maxDateQuery}&chfieldvalue=RESOLVED&f1=OP&f3=creation_ts&f4=creation_ts&keywords=meta%2C%20&keywords_type=nowords&o3=greaterthaneq&o4=lessthaneq&product=Core&product=Fenix&product=Firefox%20for%20Android&product=Firefox%20for%20Echo%20Show&product=Firefox%20for%20FireTV&product=Firefox%20for%20iOS&product=GeckoView&product=Web%20Compatibility&status_whiteboard=sci%5C-exclude&status_whiteboard_type=notregexp&v3=${minDateQuery}&v4=${maxDateQuery}&api_key=${bugzillaKey}`;
const promiseFn = () => fetch(openApiQuery);
const options = {
times: 3,
// 10 seconds should hopefully be enough for transient errors.
initialDelay: 10000,
onRetry: (error) => {
console.warn(`Retrying buzgilla query ${apiQuery} due to ${error.message}!`)
console.warn(`Retrying buzgilla query ${openApiQuery} due to ${error.message}!`)
},
};
const results = await retry(promiseFn, options)
const openResults = await retry(promiseFn, options)
.then(res => {
if (!res.ok) {
console.log(util.inspect(res, { showHidden: false, depth: null }))
@ -79,7 +84,20 @@ const getBugzilla = async (website, bugzillaKey, minDate, maxDate) => {
}
return res.json();
});
return `=HYPERLINK("${query}"; ${results.bugs.length})`;
const resolvedPromiseFn = () => fetch(resolvedApiQuery);
options.onRetry = (error) => {
console.warn(`Retrying buzgilla query ${resolvedApiQuery} due to ${error.message}!`)
};
const resolvedResults = await retry(resolvedPromiseFn, options)
.then(res => {
if (!res.ok) {
console.log(util.inspect(res, { showHidden: false, depth: null }))
throw new Error("Bugzilla query failed!");
}
return res.json();
});
const results = openResults.bugs.concat(resolvedResults.bugs);
return `=HYPERLINK("${openQuery}"; ${results.length})`;
}
/**

Просмотреть файл

@ -23,7 +23,7 @@ const fetchList = async (size = 500, directory = "data/", date) => {
.then(res => {
if (!res.ok ||
res.headers.get('content-type') !== 'text/plain; charset=utf-8') {
throw new Error("Latest list ID not found!");
throw new Error(`Request for ${ID_URL} returned status ${res.status}!`);
}
return res.text();
});