-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2236 from navikt/unpublish-old-news
Funksjonalitet for avpublisering av gamle nyheter og pressemeldinger
- Loading branch information
Showing
65 changed files
with
525 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// WARNING: This file was automatically generated by "no.item.xp.codegen". You may lose your changes if you edit it. | ||
export type ArchiveOldNews = { | ||
|
||
}; |
2 changes: 1 addition & 1 deletion
2
src/main/resources/admin/widgets/archive-restore/query/archive-query-response.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/admin/widgets/dashboard-content/utils/audit-log/auditlog-query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { QueryDsl } from '/lib/xp/node'; | ||
import { createOrUpdateSchedule } from '../scheduling/schedule-job'; | ||
import { APP_DESCRIPTOR } from '../constants'; | ||
import { ContentDescriptor } from '../../types/content-types/content-config'; | ||
import { MainArticle } from '@xp-types/site/content-types'; | ||
import { runInContext } from '../context/run-in-context'; | ||
import { findAndArchiveOldContent } from './batch-archiving'; | ||
|
||
const ONE_YEAR_MS = 1000 * 3600 * 24 * 365; | ||
const TWO_YEARS_MS = ONE_YEAR_MS * 2; | ||
|
||
const MONDAY_0700_CRON = '0 7 * * 1'; | ||
|
||
const pressReleasesQuery: QueryDsl = { | ||
boolean: { | ||
must: [ | ||
{ | ||
term: { | ||
field: 'type', | ||
value: 'no.nav.navno:main-article' satisfies ContentDescriptor, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
field: 'data.contentType', | ||
value: 'pressRelease' satisfies MainArticle['contentType'], | ||
}, | ||
}, | ||
], | ||
}, | ||
} as const; | ||
|
||
const newsQuery: QueryDsl = { | ||
boolean: { | ||
should: [ | ||
{ | ||
boolean: { | ||
must: [ | ||
{ | ||
term: { | ||
field: 'type', | ||
value: 'no.nav.navno:main-article' satisfies ContentDescriptor, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
field: 'data.contentType', | ||
value: 'news' satisfies MainArticle['contentType'], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
term: { | ||
field: 'type', | ||
value: 'no.nav.navno:current-topic-page' satisfies ContentDescriptor, | ||
}, | ||
}, | ||
], | ||
}, | ||
} as const; | ||
|
||
export const archiveOldNews = () => | ||
runInContext({ asAdmin: true }, () => { | ||
findAndArchiveOldContent({ | ||
query: pressReleasesQuery, | ||
maxAgeMs: TWO_YEARS_MS, | ||
jobName: 'pressReleases', | ||
}); | ||
|
||
findAndArchiveOldContent({ | ||
query: newsQuery, | ||
maxAgeMs: ONE_YEAR_MS, | ||
jobName: 'news', | ||
}); | ||
}); | ||
|
||
export const activateArchiveNewsSchedule = () => { | ||
createOrUpdateSchedule({ | ||
jobName: 'archive-old-news', | ||
jobSchedule: { | ||
type: 'CRON', | ||
value: MONDAY_0700_CRON, | ||
timeZone: 'GMT+2:00', | ||
}, | ||
taskDescriptor: `${APP_DESCRIPTOR}:archive-old-news`, | ||
taskConfig: {}, | ||
}); | ||
}; |
Oops, something went wrong.