Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ name: Deploy to Firebase Hosting on merge
push:
branches:
- main
permissions:
Comment thread
chase-manning marked this conversation as resolved.
checks: write
jobs:
build_and_deploy:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

name: Deploy to Firebase Hosting on PR
'on': pull_request
permissions:
Comment thread
chase-manning marked this conversation as resolved.
checks: write
pull-requests: write
jobs:
build_and_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
Expand Down
20 changes: 14 additions & 6 deletions src/app/dog-rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import { getItemMetadata, ItemType } from "./item-metadata";
const MIN_LOOKS_PERCENT = 0.05; // 5%
const MAX_LOOKS_PERCENT = 0.5; // 50%

// Geometrically-spaced weights so each step is a consistent ~50% increase.
// Preserves the 5:1 max/min ratio (r^4 = 5, r β‰ˆ 1.495).
const IMPORTANCE_WEIGHTS = [1.0, 1.5, 2.24, 3.34, 5.0];
const getImportanceWeight = (importance: number | null): number => {
const clamped = Math.max(1, Math.min(5, Math.round(importance || 3)));
return IMPORTANCE_WEIGHTS[clamped - 1];
};

export interface DogRatingType {
rating: number;
elo: number;
Expand Down Expand Up @@ -53,9 +61,9 @@ const dogRating = (dogs: DogType[], quiz: QuizType): DogRatings => {
if (isRating) {
const dogValue = (dogs[i] as any)[category][trait];
if (ratingQuestion.value) {
const importance = question.importance || 3;
const weight = getImportanceWeight(question.importance);
const closeness = 4 - Math.abs(dogValue - ratingQuestion.value);
dogRating.rating += closeness * importance;
dogRating.rating += closeness * weight;
}
}

Expand All @@ -65,16 +73,16 @@ const dogRating = (dogs: DogType[], quiz: QuizType): DogRatings => {
if (selected.length > 0) {
if (typeof dogValue === "string") {
if (selected.includes(dogValue)) {
const importance = question.importance || 3;
dogRating.rating += importance * 2;
const weight = getImportanceWeight(question.importance);
dogRating.rating += weight * 2;
}
}

if (Array.isArray(dogValue)) {
for (const t of dogValue) {
if (selected.includes(t)) {
const importance = question.importance || 3;
dogRating.rating += importance;
const weight = getImportanceWeight(question.importance);
dogRating.rating += weight;
}
}
}
Expand Down
Loading