-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from coronasafe/improve_accuracy_calculation
Improve accuracy calculation
- Loading branch information
Showing
11 changed files
with
225 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,4 +85,4 @@ | |
"engines": { | ||
"node": ">=20.0.0" | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
prisma/migrations/20240609170140_change_accuracy_to_json/migration.sql
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 @@ | ||
-- Rename the existing column to a temporary name | ||
ALTER TABLE "VitalsStat" RENAME COLUMN "accuracy" TO "accuracy_temp"; | ||
ALTER TABLE "VitalsStat" RENAME COLUMN "cumulativeAccuracy" TO "cumulativeAccuracy_temp"; | ||
|
||
-- Add the new column with the Json type | ||
ALTER TABLE "VitalsStat" ADD COLUMN "accuracy" Json; | ||
ALTER TABLE "VitalsStat" ADD COLUMN "cumulativeAccuracy" Json; | ||
|
||
-- Copy the data from the old column to the new column, converting floats to JSON | ||
UPDATE "VitalsStat" SET "accuracy" = json_build_object('overall', "accuracy_temp", 'metrics', '[]'::json); | ||
UPDATE "VitalsStat" SET "cumulativeAccuracy" = json_build_object('overall', "cumulativeAccuracy_temp", 'metrics', '[]'::json); | ||
|
||
-- Drop the temporary column | ||
ALTER TABLE "VitalsStat" DROP COLUMN "accuracy_temp"; | ||
ALTER TABLE "VitalsStat" DROP COLUMN "cumulativeAccuracy_temp"; | ||
|
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,18 @@ | ||
import { observationData } from "@/controller/ObservationController"; | ||
import { hostname } from "@/utils/configs"; | ||
import { makeDataDumpToJson } from "@/utils/makeDataDump"; | ||
|
||
export async function observationsS3Dump() { | ||
const data = [...observationData]; | ||
makeDataDumpToJson(data, `${hostname}/${new Date().getTime()}.json`, { | ||
slug: "s3_observations_dump", | ||
options: { | ||
schedule: { | ||
type: "crontab", | ||
value: "30 * * * *", | ||
}, | ||
}, | ||
}); | ||
|
||
observationData.splice(0, data.length); | ||
} |
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.