Skip to content

Commit

Permalink
MIMIR-1740: Fixed codesmells sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
ssb-cgn committed May 3, 2023
1 parent 812f407 commit ce2aca9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/resources/services/news/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ exports.get = get
function getNews(mainSubjects: Array<Content<Page, DefaultPageConfig>>): Array<News> {
const from: string = subDays(new Date(), 1).toISOString()
const to: string = new Date().toISOString()
const baseUrl: string = (app.config && app.config['ssb.baseUrl']) || ''
const serverOffsetInMinutes: number = parseInt(app.config && app.config['serverOffsetInMs']) || 0
const baseUrl: string = app.config?.['ssb.baseUrl'] || ''
const serverOffsetInMinutes: number = parseInt(app.config?.['serverOffsetInMs']) || 0
const timeZoneIso: string = getTimeZoneIso(serverOffsetInMinutes)

//TODO: Fjerne når datoformat er verifisert i de forskjellige miljøene
Expand Down Expand Up @@ -106,15 +106,14 @@ function getStatisticsNews(mainSubjects: Array<Content<Page, DefaultPageConfig>>
.join(',')})`,
}).hits as unknown as Array<Content<Statistics & Statistic, SEO>>

const baseUrl: string = (app.config && app.config['ssb.baseUrl']) || ''
const serverOffsetInMS: number = parseInt(app.config && app.config['serverOffsetInMs']) || 0
const baseUrl: string = app.config?.['ssb.baseUrl'] || ''
const serverOffsetInMS: number = parseInt(app.config?.['serverOffsetInMs']) || 0
const timeZoneIso: string = getTimeZoneIso(serverOffsetInMS)
statistics.forEach((statistic) => {
const statreg: StatisticInListing | undefined = statregStatistics.find(
(s) => s.id.toString() === statistic.data.statistic
)
const variant: VariantInListing | undefined =
statreg && statreg.variants && statreg.variants[0] ? statreg.variants[0] : undefined
const variant: VariantInListing | undefined = statreg?.variants?.[0] || undefined
let pubDate: string | undefined
if (variant) {
const previousReleaseSameDayNow: boolean = variant.previousRelease
Expand Down Expand Up @@ -167,7 +166,7 @@ function formatPubDateStatistic(date: string, timeZoneIso: string): string {
}

function testPubDates() {
const serverOffsetInMS: number = parseInt(app.config && app.config['serverOffsetInMs']) || 0
const serverOffsetInMS: number = parseInt(app.config?.['serverOffsetInMs']) || 0
const timeZoneIso: string = getTimeZoneIso(serverOffsetInMS)

const ArtikkelDate = formatPubDateArticle('2023-03-20T07:00:00Z', serverOffsetInMS, timeZoneIso)
Expand Down

0 comments on commit ce2aca9

Please sign in to comment.