Skip to content

Commit

Permalink
Merge pull request #1875 from statisticsnorway/MIMIR-1740-rss-publish…
Browse files Browse the repository at this point in the history
…date

MIMIR-1740:Changed from publish.first to publish.from rss news
  • Loading branch information
ssb-cgn authored May 4, 2023
2 parents 050d13a + ce2aca9 commit 09d28dd
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 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 All @@ -66,8 +66,8 @@ function getNews(mainSubjects: Array<Content<Page, DefaultPageConfig>>): Array<N
query: `_path LIKE "/content${mainSubject._path}/*" AND range("publish.from", instant("${from}"), instant("${to}"))`,
}).hits as unknown as Array<Content<Article, SEO>>
articles.forEach((article) => {
const pubDate: string | undefined = article.publish?.first
? formatPubDateArticle(article.publish.first, serverOffsetInMinutes, timeZoneIso)
const pubDate: string | undefined = article.publish?.from
? formatPubDateArticle(article.publish.from, serverOffsetInMinutes, timeZoneIso)
: undefined
if (pubDate) {
news.push({
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 09d28dd

Please sign in to comment.