Compare commits

..

No commits in common. "e3c81995980621dd06b1277d6db0af6b25383cc6" and "cef544fda4653d2ce46beb15cae4664369f52e17" have entirely different histories.

5 changed files with 23 additions and 43 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "Sage's BitBucket Addon", "name": "Sage's BitBucket Addon",
"description": "Ensure searches don't include forks (and other enhancements)", "description": "Ensure searches don't include forks (and other enhancements)",
"version": "1.0.24", "version": "1.0.22",
"manifest_version": 2, "manifest_version": 2,
"browser_specific_settings": { "browser_specific_settings": {
"gecko": { "gecko": {

View File

@ -1,10 +1,4 @@
if (location.toString().includes('/pull-requests?create')) { if (location.toString().includes('/pull-requests?create')) {
const addOnly = async () => ['ADD']
const allProjects = async () => fetch('https://git.add123.com/rest/api/latest/projects')
.then(resp => resp.json())
.then(async ({ values }) => values.map(project => project.key).filter(key => !['GRAV', 'TEST'].includes(key)))
const names = [ const names = [
"Tam Nguyen", "Tam Nguyen",
"David Daniel", "David Daniel",
@ -21,37 +15,28 @@ if (location.toString().includes('/pull-requests?create')) {
const urlPrefix = 'https://git.add123.com/rest/api/latest' const urlPrefix = 'https://git.add123.com/rest/api/latest'
const getPullRequestsForProject = async project => { fetch(`${urlPrefix}/projects/ADD/repos?limit=999`)
return await fetch(`${urlPrefix}/projects/${project}/repos?limit=999`) .then(resp => resp.json())
.then(resp => resp.json()) .then(async ({values: allRepos}) => {
.then(async (resp) => { const prListUrls = allRepos.map(repo => `${urlPrefix}/projects/ADD/repos/${repo.slug}/pull-requests`)
if (!resp) { const allPullRequests = (await Promise.all(
return [] prListUrls.map(async prListUrl => await fetch(prListUrl).then(resp => resp.json())))
} ).flatMap(({values}) => values)
const { values: allRepos } = resp
const prListUrls = allRepos.map(repo => `${urlPrefix}/projects/${project}/repos/${repo.slug}/pull-requests`)
return (await Promise.all(
prListUrls.map(async prListUrl => await fetch(prListUrl).then(resp => resp.json())))
).flatMap(({values}) => values)})
}
allProjects().then(async allProjects => { const reviewerCounts = Object.fromEntries(names.map(name => [name, 0]))
const allPullRequests = (await Promise.all(allProjects.map(async project => await getPullRequestsForProject(project)))).flatMap(a => a) allPullRequests.forEach(({reviewers}) => {
const reviewerCounts = Object.fromEntries(names.map(name => [name, 0])) reviewers?.map(r => r.user.displayName)
allPullRequests.forEach(({reviewers}) => { .filter(displayName => !["Chris Gamache", "Tom Keels"].includes(displayName))
reviewers?.map(r => r.user.displayName) .forEach(displayName => {
.filter(displayName => names.includes(displayName)) reviewerCounts[displayName] ??= 0
//.filter(displayName => !["Chris Gamache", "Tom Keels", "Todd Sherrin", "Kelly Gunter", "Mark Garrett"].includes(displayName)) reviewerCounts[displayName] += 1
.forEach(displayName => { })
reviewerCounts[displayName] ??= 0 })
reviewerCounts[displayName] += 1 const sortedCounts = Object.entries(reviewerCounts)
}) .map(([name, count]) => ({ name, count }))
}) .toSorted((a, b) => a.count - b.count)
const sortedCounts = Object.entries(reviewerCounts)
.map(([name, count]) => ({name, count}))
.toSorted((a, b) => a.count - b.count)
const tryDisplay = () => setTimeout(() => { const tryDisplay = () => setTimeout(() => {
if (!sortedCounts.length || document.getElementById('reviewer-counts')) { if (document.getElementById('reviewer-counts')) {
return return
} }
const formBodyMain = document.querySelector('.create-pull-request-form .form-body .form-body-main') const formBodyMain = document.querySelector('.create-pull-request-form .form-body .form-body-main')
@ -71,10 +56,6 @@ if (location.toString().includes('/pull-requests?create')) {
reviewerCountsNode.appendChild(listItem) reviewerCountsNode.appendChild(listItem)
}) })
const projectHeadsUp = document.createElement('div')
projectHeadsUp.innerText = 'Note: this list does not take into account any projects that you do not have access to. E.g. STA'
reviewerCountsNode.appendChild(projectHeadsUp)
const label = countsParent.querySelector('.form-label') const label = countsParent.querySelector('.form-label')
label.innerText = 'Now reviewing' label.innerText = 'Now reviewing'
const message = countsParent.querySelector('.form-field-content') const message = countsParent.querySelector('.form-field-content')

View File

@ -65,8 +65,7 @@ const addVariableClickers = skipExpandos => {
getVarElements() getVarElements()
.forEach(e => { .forEach(e => {
e.onmouseover = () => selectVar(e.innerText) e.onclick = () => selectVar(e.innerText)
e.onmouseleave = () => selectVar('zzzzz')
e.ondblclick = () => { e.ondblclick = () => {
let searchBox = getSearchBox() let searchBox = getSearchBox()
@ -87,7 +86,7 @@ addFix(() => {
const styleSheet = document.createElement('style') const styleSheet = document.createElement('style')
styleSheet.innerText = ` styleSheet.innerText = `
.${selectedClass} { .${selectedClass} {
background: rgba(255, 253, 170, 0.1) !important; background: rgb(255, 253, 170) !important;
border-radius: 3px; border-radius: 3px;
padding: 2px !important; padding: 2px !important;
margin: -2px !important; margin: -2px !important;