diff --git a/components/components.templ b/components/components.templ
index 709883e..38b91a3 100644
--- a/components/components.templ
+++ b/components/components.templ
@@ -311,7 +311,7 @@ templ PageTable(rows TableRows, q queries.Query, counts queries.Counts, pages Pa
}
// About page
-templ PageAbout(){
+templ PageAbout(countTaxa, countLastFetched int){
@Page() {
@templ.Raw(_aboutPage)
@@ -322,6 +322,8 @@ templ PageAbout(){
Cron Interval: { fmt.Sprint(internal.Config.CronJobIntervalSec) } seconds
Taxa per Cron: { gbif.SampleRows }
User Agent Prefix: { internal.Config.UserAgentPrefix }
+ Total Taxa in DB: { printer.Sprintln(countTaxa) }
+ Fetched Taxa, past 12 months: { printer.Sprintln(countLastFetched) }
diff --git a/pkg/queries/queries.go b/pkg/queries/queries.go
index e7732c2..925d671 100644
--- a/pkg/queries/queries.go
+++ b/pkg/queries/queries.go
@@ -268,3 +268,21 @@ func getFieldValue(fieldValue reflect.Value) (interface{}, bool) {
}
return fieldValue.Interface(), true
}
+
+func GetCountTotalTaxa(db *sql.DB) int {
+ var count int
+ err := sq.Select("COUNT(TaxonID)").From("taxa").Where(sq.Eq{"isSynonym": false}).RunWith(db).QueryRow().Scan(&count)
+ if err != nil {
+ slog.Error("Failed to get taxa count", "error", err)
+ }
+ return count
+}
+
+func GetCountFetchedLastTwelveMonths(db *sql.DB) int {
+ var count int
+ err := sq.Select("COUNT(TaxonID)").From("taxa").Where("LastFetch > CURRENT_DATE - INTERVAL 12 MONTH").Where(sq.Eq{"isSynonym": false}).RunWith(db).QueryRow().Scan(&count)
+ if err != nil {
+ slog.Error("Failed to get taxa count", "error", err)
+ }
+ return count
+}
diff --git a/server.go b/server.go
index 12dcb99..1aabec6 100644
--- a/server.go
+++ b/server.go
@@ -111,9 +111,12 @@ func index(c echo.Context) error {
}
func about(c echo.Context) error {
+ countTaxa := queries.GetCountTotalTaxa(internal.DB)
+ countLastFetched := queries.GetCountFetchedLastTwelveMonths(internal.DB)
+
return render(c,
http.StatusAccepted,
- components.PageAbout())
+ components.PageAbout(countTaxa, countLastFetched))
}
/* Partials */