Skip to content

Commit

Permalink
chore: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaszkowic committed Jun 20, 2024
1 parent 30ff28b commit 9bf337b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions supabase/functions/gdk_stats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ interface GdkStats {
mostFrequentTreeSpecies: TreeSpecies[];
}

const HARD_CODED_TREE_COUNT = 885825;
// As trees table barely changes, we can hardcode the values
// It would be too expensive to calculate on each request

// SELECT COUNT(1) FROM trees;
const TREE_COUNT = 885825;

// SELECT trees.gattung_deutsch, (COUNT(1) * 100.0) / (SELECT COUNT(1) FROM trees) AS percentage
// FROM trees
// GROUP BY trees.gattung_deutsch
// ORDER BY COUNT(1) DESC
// LIMIT 20;
const MOST_FREQUENT_TREE_SPECIES: TreeSpecies[] = [
{ speciesName: "AHORN", percentage: 22.8128580701605848 },
{ speciesName: "LINDE", percentage: 21.5930911861823724 },
Expand Down Expand Up @@ -109,7 +119,7 @@ const handler = async (request: Request): Promise<Response> => {
]);

const stats: GdkStats = {
numTrees: HARD_CODED_TREE_COUNT,
numTrees: TREE_COUNT,
numPumps: numPumps,
numActiveUsers: usersCount,
numWateringsThisYear: wateringsCount,
Expand Down

0 comments on commit 9bf337b

Please sign in to comment.