-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9279108
commit fdcec4a
Showing
15 changed files
with
256 additions
and
66 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,21 @@ | ||
-- CreateTable | ||
CREATE TABLE "GoalRank" ( | ||
"id" TEXT NOT NULL DEFAULT gen_random_uuid(), | ||
"activityId" TEXT NOT NULL, | ||
"goalId" TEXT NOT NULL, | ||
"value" DOUBLE PRECISION NOT NULL, | ||
|
||
CONSTRAINT "GoalRank_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "GoalRank_activityId_idx" ON "GoalRank"("activityId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "GoalRank_activityId_goalId_key" ON "GoalRank"("activityId", "goalId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GoalRank" ADD CONSTRAINT "GoalRank_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "Activity"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GoalRank" ADD CONSTRAINT "GoalRank_goalId_fkey" FOREIGN KEY ("goalId") REFERENCES "Goal"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
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
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,16 @@ | ||
export const getMiddleRank = (values: { low?: number | null; high?: number | null }): number => { | ||
const low = values.low ?? Number.MIN_VALUE; | ||
const high = values.high ?? Number.MAX_VALUE; | ||
if (low === high) throw new Error('Exhausted precision'); | ||
if (low > high) throw new Error('Low cannot be greater than high'); | ||
const middle = low + (high - low) / 2; | ||
if (middle === low || middle === high) throw new Error('Exhausted precision'); | ||
return middle; | ||
}; | ||
|
||
export const getRankSeries = (count: number) => { | ||
const start = 1; | ||
const end = 1000; | ||
const step = (end - start) / Math.max(count - 1, 1); | ||
return Array.from({ length: count }, (v, i) => start + i * step); | ||
}; |
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
Oops, something went wrong.