Deprecate [Bountysource] service (#10371)
This commit is contained in:
committed by
GitHub
parent
47229ecc07
commit
852d02d662
@@ -1,47 +1,11 @@
|
|||||||
import Joi from 'joi'
|
import { deprecatedService } from '../index.js'
|
||||||
import { metric } from '../text-formatters.js'
|
|
||||||
import { BaseJsonService, pathParams } from '../index.js'
|
|
||||||
|
|
||||||
const schema = Joi.object({ activity_total: Joi.number().required() })
|
export const Bountysource = deprecatedService({
|
||||||
|
category: 'funding',
|
||||||
export default class Bountysource extends BaseJsonService {
|
route: {
|
||||||
static category = 'funding'
|
base: 'bountysource/team',
|
||||||
static route = { base: 'bountysource/team', pattern: ':team/activity' }
|
pattern: ':team/activity',
|
||||||
|
},
|
||||||
static openApi = {
|
label: 'bountysource',
|
||||||
'/bountysource/team/{team}/activity': {
|
dateAdded: new Date('2024-07-18'),
|
||||||
get: {
|
})
|
||||||
summary: 'Bountysource',
|
|
||||||
parameters: pathParams({
|
|
||||||
name: 'team',
|
|
||||||
example: 'mozilla-core',
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
static defaultBadgeData = { label: 'bounties' }
|
|
||||||
|
|
||||||
static render({ total }) {
|
|
||||||
return {
|
|
||||||
message: metric(total),
|
|
||||||
color: 'brightgreen',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fetch({ team }) {
|
|
||||||
const url = `https://api.bountysource.com/teams/${team}`
|
|
||||||
return this._requestJson({
|
|
||||||
schema,
|
|
||||||
url,
|
|
||||||
options: {
|
|
||||||
headers: { Accept: 'application/vnd.bountysource+json; version=2' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async handle({ team }) {
|
|
||||||
const json = await this.fetch({ team })
|
|
||||||
return this.constructor.render({ total: json.activity_total })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { isMetric } from '../test-validators.js'
|
|
||||||
import { ServiceTester } from '../tester.js'
|
import { ServiceTester } from '../tester.js'
|
||||||
|
|
||||||
export const t = new ServiceTester({
|
export const t = new ServiceTester({
|
||||||
@@ -6,16 +5,7 @@ export const t = new ServiceTester({
|
|||||||
title: 'Bountysource',
|
title: 'Bountysource',
|
||||||
})
|
})
|
||||||
|
|
||||||
t.create('bounties (valid)')
|
t.create('bounties').get('/team/mozilla-core/activity.json').expectBadge({
|
||||||
.get('/team/mozilla-core/activity.json')
|
label: 'bountysource',
|
||||||
.expectBadge({
|
message: 'no longer available',
|
||||||
label: 'bounties',
|
})
|
||||||
message: isMetric,
|
|
||||||
})
|
|
||||||
|
|
||||||
t.create('bounties (invalid team)')
|
|
||||||
.get('/team/not-a-real-team/activity.json')
|
|
||||||
.expectBadge({
|
|
||||||
label: 'bounties',
|
|
||||||
message: 'not found',
|
|
||||||
})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user