feat(recommendations): MIKRO MEAL-1 måltids-lämplighet i rankningen (nedvikta frukost/dessert vid huvudmåltid)
This commit is contained in:
@@ -383,6 +383,7 @@ export async function recommendationRoutes(app: FastifyInstance) {
|
|||||||
ratingCount: recipe.ratingCount,
|
ratingCount: recipe.ratingCount,
|
||||||
peakSeasons: recipe.peakSeasons,
|
peakSeasons: recipe.peakSeasons,
|
||||||
holidayTags: recipe.holidayTags,
|
holidayTags: recipe.holidayTags,
|
||||||
|
mealTypes: recipe.mealTypes,
|
||||||
spiceLevel: recipe.spiceLevel,
|
spiceLevel: recipe.spiceLevel,
|
||||||
coverage,
|
coverage,
|
||||||
daysSinceLastCooked: lastDate
|
daysSinceLastCooked: lastDate
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ export function scoreCandidate(
|
|||||||
parts.cookingAssumptionFit = 0;
|
parts.cookingAssumptionFit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 16. Måltids-lämplighet: nedvikta lätta övergångsrätter (frukost/dessert) vid huvudmåltid.
|
||||||
|
const mainMeal = ctx.mealType === "dinner" || ctx.mealType === "lunch";
|
||||||
|
const crossover =
|
||||||
|
(candidate.mealTypes ?? []).includes("breakfast") || (candidate.mealTypes ?? []).includes("dessert");
|
||||||
|
parts.mealFit = mainMeal && crossover ? 0.15 : 1;
|
||||||
|
|
||||||
const score = weightedSum(parts, weights);
|
const score = weightedSum(parts, weights);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export interface RecommendationCandidate {
|
|||||||
ratingCount: number;
|
ratingCount: number;
|
||||||
peakSeasons: Season[];
|
peakSeasons: Season[];
|
||||||
holidayTags: string[];
|
holidayTags: string[];
|
||||||
|
mealTypes?: MealType[];
|
||||||
spiceLevel: number;
|
spiceLevel: number;
|
||||||
coverage: CoverageResult;
|
coverage: CoverageResult;
|
||||||
/** Dagar sedan hushållet senast lagade receptet (null = aldrig). */
|
/** Dagar sedan hushållet senast lagade receptet (null = aldrig). */
|
||||||
@@ -104,6 +105,7 @@ export interface ScoringWeights {
|
|||||||
variety: number;
|
variety: number;
|
||||||
weather: number;
|
weather: number;
|
||||||
craving: number;
|
craving: number;
|
||||||
|
mealFit: number;
|
||||||
/** Nya S1-vikter; 0 om personalisering är av. */
|
/** Nya S1-vikter; 0 om personalisering är av. */
|
||||||
memoryFit: number;
|
memoryFit: number;
|
||||||
tasteFit: number;
|
tasteFit: number;
|
||||||
@@ -123,6 +125,7 @@ export const DEFAULT_WEIGHTS: ScoringWeights = {
|
|||||||
variety: 6,
|
variety: 6,
|
||||||
weather: 3,
|
weather: 3,
|
||||||
craving: 15,
|
craving: 15,
|
||||||
|
mealFit: 12,
|
||||||
memoryFit: 6,
|
memoryFit: 6,
|
||||||
tasteFit: 6,
|
tasteFit: 6,
|
||||||
cookingAssumptionFit: 4,
|
cookingAssumptionFit: 4,
|
||||||
@@ -155,6 +158,7 @@ export const TASTE_VIEW_WEIGHTS: ScoringWeights = {
|
|||||||
variety: 3,
|
variety: 3,
|
||||||
weather: 1,
|
weather: 1,
|
||||||
craving: 25,
|
craving: 25,
|
||||||
|
mealFit: 12,
|
||||||
memoryFit: 12,
|
memoryFit: 12,
|
||||||
tasteFit: 12,
|
tasteFit: 12,
|
||||||
cookingAssumptionFit: 6,
|
cookingAssumptionFit: 6,
|
||||||
@@ -174,6 +178,7 @@ export const HEALTH_VIEW_WEIGHTS: ScoringWeights = {
|
|||||||
variety: 4,
|
variety: 4,
|
||||||
weather: 2,
|
weather: 2,
|
||||||
craving: 5,
|
craving: 5,
|
||||||
|
mealFit: 12,
|
||||||
memoryFit: 3,
|
memoryFit: 3,
|
||||||
tasteFit: 3,
|
tasteFit: 3,
|
||||||
cookingAssumptionFit: 4,
|
cookingAssumptionFit: 4,
|
||||||
@@ -193,6 +198,7 @@ export const PANTRY_VIEW_WEIGHTS: ScoringWeights = {
|
|||||||
variety: 2,
|
variety: 2,
|
||||||
weather: 1,
|
weather: 1,
|
||||||
craving: 5,
|
craving: 5,
|
||||||
|
mealFit: 12,
|
||||||
memoryFit: 4,
|
memoryFit: 4,
|
||||||
tasteFit: 4,
|
tasteFit: 4,
|
||||||
cookingAssumptionFit: 8,
|
cookingAssumptionFit: 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user