Feat/SW-3287 campaign start end
Approved-by: Matilda Landström
This commit is contained in:
@@ -2,15 +2,23 @@
|
||||
|
||||
#import "../../Fragments/CampaignPage/Hero.graphql"
|
||||
|
||||
query GetCampaignPagesByHotelUid($locale: String!, $hotelPageUid: String!) {
|
||||
query GetCampaignPagesByHotelUid(
|
||||
$locale: String!
|
||||
$hotelPageUid: String!
|
||||
$today: DateTime!
|
||||
) {
|
||||
all_campaign_page(
|
||||
locale: $locale
|
||||
where: {
|
||||
OR: [
|
||||
{ included_hotels: { list_1: { hotel_page: { uid: $hotelPageUid } } } }
|
||||
{ included_hotels: { list_2: { hotel_page: { uid: $hotelPageUid } } } }
|
||||
]
|
||||
AND: [
|
||||
{ OR: [{ startdate: null }, { startdate_lte: $today }] }
|
||||
{ OR: [{ enddate: null }, { enddate_gte: $today }] }
|
||||
]
|
||||
}
|
||||
locale: $locale
|
||||
) {
|
||||
items {
|
||||
heading
|
||||
@@ -28,15 +36,23 @@ query GetCampaignPagesByHotelUid($locale: String!, $hotelPageUid: String!) {
|
||||
}
|
||||
}
|
||||
|
||||
query GetCampaignPagesByHotelUidRefs($locale: String!, $hotelPageUid: String!) {
|
||||
query GetCampaignPagesByHotelUidRefs(
|
||||
$locale: String!
|
||||
$hotelPageUid: String!
|
||||
$today: DateTime!
|
||||
) {
|
||||
all_campaign_page(
|
||||
locale: $locale
|
||||
where: {
|
||||
OR: [
|
||||
{ included_hotels: { list_1: { hotel_page: { uid: $hotelPageUid } } } }
|
||||
{ included_hotels: { list_2: { hotel_page: { uid: $hotelPageUid } } } }
|
||||
]
|
||||
AND: [
|
||||
{ OR: [{ startdate: null }, { startdate_lte: $today }] }
|
||||
{ OR: [{ enddate: null }, { enddate_gte: $today }] }
|
||||
]
|
||||
}
|
||||
locale: $locale
|
||||
) {
|
||||
items {
|
||||
...CampaignPageRef
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { notFound } from "../../../errors"
|
||||
@@ -103,6 +104,7 @@ export async function getCampaignPagesByHotelPageUid(
|
||||
hotelPageUid: string,
|
||||
lang: Lang
|
||||
) {
|
||||
const today = dt().format("YYYY-MM-DD")
|
||||
const getCampaignPagesByHotelUidRefsCounter = createCounter(
|
||||
"trpc.contentstack",
|
||||
"campaignPage.byHotelUid.get.refs"
|
||||
@@ -111,6 +113,7 @@ export async function getCampaignPagesByHotelPageUid(
|
||||
getCampaignPagesByHotelUidRefsCounter.init({
|
||||
lang,
|
||||
hotelPageUid,
|
||||
today,
|
||||
})
|
||||
|
||||
metricsGetCampaignPagesByHotelUidRefs.start()
|
||||
@@ -120,9 +123,14 @@ export async function getCampaignPagesByHotelPageUid(
|
||||
{
|
||||
locale: lang,
|
||||
hotelPageUid,
|
||||
today,
|
||||
},
|
||||
{
|
||||
key: generateRefsResponseTag(lang, hotelPageUid, "hotel_page_campaigns"),
|
||||
key: generateRefsResponseTag(
|
||||
lang,
|
||||
`${hotelPageUid}-${today}`,
|
||||
"hotel_page_campaigns"
|
||||
),
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
@@ -155,6 +163,7 @@ export async function getCampaignPagesByHotelPageUid(
|
||||
getCampaignPagesByHotelUidCounter.init({
|
||||
lang,
|
||||
hotelPageUid,
|
||||
today,
|
||||
})
|
||||
|
||||
metricsGetCampaignPagesByHotelUid.start()
|
||||
@@ -164,6 +173,7 @@ export async function getCampaignPagesByHotelPageUid(
|
||||
{
|
||||
locale: lang,
|
||||
hotelPageUid,
|
||||
today,
|
||||
},
|
||||
{
|
||||
key: tags,
|
||||
|
||||
Reference in New Issue
Block a user