feat(dashboard): enrich demand calendar locations
This commit is contained in:
@@ -16,6 +16,7 @@ export interface GetDashboardDemandInput {
|
||||
|
||||
export interface DemandCalendarLocationSummary {
|
||||
countryCode: string | null;
|
||||
countryName: string | null;
|
||||
federalState: string | null;
|
||||
metroCityName: string | null;
|
||||
resourceCount: number;
|
||||
@@ -71,11 +72,13 @@ function toIsoDate(value: Date): string {
|
||||
|
||||
function buildLocationKey(input: {
|
||||
countryCode: string | null | undefined;
|
||||
countryName: string | null | undefined;
|
||||
federalState: string | null | undefined;
|
||||
metroCityName: string | null | undefined;
|
||||
}): string {
|
||||
return JSON.stringify({
|
||||
countryCode: input.countryCode ?? null,
|
||||
countryName: input.countryName ?? null,
|
||||
federalState: input.federalState ?? null,
|
||||
metroCityName: input.metroCityName ?? null,
|
||||
});
|
||||
@@ -118,6 +121,7 @@ function summarizeCalendarLocations(
|
||||
id: string;
|
||||
availability: WeekdayAvailability;
|
||||
countryCode: string | null | undefined;
|
||||
countryName: string | null | undefined;
|
||||
federalState: string | null | undefined;
|
||||
metroCityName: string | null | undefined;
|
||||
}>,
|
||||
@@ -145,11 +149,13 @@ function summarizeCalendarLocations(
|
||||
|
||||
const locationKey = buildLocationKey({
|
||||
countryCode: resource.countryCode,
|
||||
countryName: resource.countryName,
|
||||
federalState: resource.federalState,
|
||||
metroCityName: resource.metroCityName,
|
||||
});
|
||||
const existing = locationMap.get(locationKey) ?? {
|
||||
countryCode: resource.countryCode ?? null,
|
||||
countryName: resource.countryName ?? null,
|
||||
federalState: resource.federalState ?? null,
|
||||
metroCityName: resource.metroCityName ?? null,
|
||||
resourceCount: 0,
|
||||
@@ -197,6 +203,7 @@ export async function getDashboardDemand(
|
||||
availability: resource.availability as unknown as WeekdayAvailability,
|
||||
countryId: resource.countryId,
|
||||
countryCode: resource.country?.code,
|
||||
countryName: resource.country?.name,
|
||||
federalState: resource.federalState,
|
||||
metroCityId: resource.metroCityId,
|
||||
metroCityName: resource.metroCity?.name,
|
||||
|
||||
@@ -25,6 +25,7 @@ export const DASHBOARD_PLANNING_ALLOCATION_INCLUDE = {
|
||||
country: {
|
||||
select: {
|
||||
code: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
metroCity: {
|
||||
|
||||
Reference in New Issue
Block a user