-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: first gdk stats * feat: monthly waterings * feat: mostFrequentTreeSpecies * fix: typo * chore: refactoring * fix: error handling and env * chore: comments * feat: more database functions * feat: env var existence check * feat: more distinguishable errors * fix: console.error instead of console.log for errors * chore: cleanup * fix: env variables * fix: more restrictive cors, chore: cleanup
- Loading branch information
Showing
15 changed files
with
559 additions
and
67 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
export const loadEnvVars = (vars: string[]) => { | ||
const missingVars = vars.filter((v) => !Deno.env.get(v)); | ||
if (missingVars.length > 0) { | ||
throw new Error(`Missing environment variables: ${missingVars.join(", ")}`); | ||
} | ||
return vars.map((v) => Deno.env.get(v)); | ||
}; |
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,43 @@ | ||
export interface TreeSpecies { | ||
speciesName?: string; | ||
percentage: number; | ||
} | ||
|
||
export interface Monthly { | ||
month: string; | ||
wateringCount: number; | ||
averageAmountPerWatering: number; | ||
totalSum: number; | ||
} | ||
|
||
export interface Watering { | ||
id: string; | ||
lat: number; | ||
lng: number; | ||
amount: number; | ||
timestamp: string; | ||
} | ||
|
||
export interface TreeAdoptions { | ||
count: number; | ||
veryThirstyCount: number; | ||
} | ||
|
||
export interface GdkStats { | ||
numTrees: number; | ||
numPumps: number; | ||
numActiveUsers: number; | ||
numWateringsThisYear: number; | ||
monthlyWaterings: Monthly[]; | ||
treeAdoptions: TreeAdoptions; | ||
mostFrequentTreeSpecies: TreeSpecies[]; | ||
totalTreeSpeciesCount: number; | ||
waterings: Watering[]; | ||
monthlyWeather: MonthlyWeather[]; | ||
} | ||
|
||
export interface MonthlyWeather { | ||
month: string; | ||
averageTemperatureCelsius: number; | ||
totalRainfallLiters: number; | ||
} |
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,14 @@ | ||
export enum ErrorTypes { | ||
GdkStatsPump = "gdk_stats_pumps", | ||
GdkStatsUser = "gdk_stats_users", | ||
GdkStatsWatering = "gdk_stats_waterings", | ||
GdkStatsAdoption = "gdk_stats_adoptions", | ||
GdkStatsTreeSpecie = "gdk_stats_tree_species", | ||
GdkStatsWeather = "gdk_stats_weather", | ||
} | ||
|
||
export class GdkError extends Error { | ||
constructor(message: string, public errorType: ErrorTypes) { | ||
super(message); | ||
} | ||
} |
Oops, something went wrong.