Skip to content

Commit

Permalink
Remove duplicate currentCycleEffectiveDates()
Browse files Browse the repository at this point in the history
  • Loading branch information
corys committed Jan 25, 2022
1 parent 82fce52 commit cc8f30e
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ terminalProcedures.list = (icaos, options = defaultQueryOptions) => {
return listOne(icaos, options)
}

terminalProcedures.currentCycleEffectiveDates = async () => {
const response = await superagent
.get(BASE_URL)
.set('Accept', ACCEPT)
.timeout({ deadline: 30000 })
.retry(3)

const $ = cheerio.load(response.text)
var currentCycle = $('select#cycle > option:contains(Current)').text()
return parseEffectiveDates(currentCycle.replace(/(\n|\t)/gm, ''))
}

/**
* Returns the text and values of the targeted <select/> element
* @param {string} cycle - The target cycle to retrieve. Valid values are 'Current' or 'Next'
Expand Down Expand Up @@ -75,18 +63,17 @@ terminalProcedures.fetchCycle = fetchCycle

terminalProcedures.getCycleEffectiveDates = async (cycle = 'Current') => {
const { text: currentCycle, } = await fetchCycle(cycle)
return parseEffectiveDates(currentCycle.replace(/(\n|\t)/gm, ''))
}

terminalProcedures.currentCycleEffectiveDates = async () => {
const { text: currentCycle, } = await fetchCycle()
if (!currentCycle) {
console.warn('Could not retrieve current cycle effective dates')
console.warn(`Could not retrieve ${cycle} cycle effective dates`)
return
}
return parseEffectiveDates(currentCycle.replace(/(\n|\t)/gm, ''))
}

terminalProcedures.currentCycleEffectiveDates = async () => {
return getCycleEffectiveDates()
}

/**
* Fetch the current diagrams distribution cycle numbers (.e.g, 1813)
*/
Expand Down

0 comments on commit cc8f30e

Please sign in to comment.