From 74663ed1b6fcc872898f076d5b4ff4793929576a Mon Sep 17 00:00:00 2001 From: David Stotijn Date: Fri, 17 Dec 2021 18:12:14 +0100 Subject: [PATCH] Enumerate rollup function values --- client_test.go | 4 ++-- database.go | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/client_test.go b/client_test.go index d2af457..eb0c7c9 100644 --- a/client_test.go +++ b/client_test.go @@ -191,7 +191,7 @@ func TestFindDatabaseByID(t *testing.T) { "relation_property_name": "Meals", "rollup_property_id": "title", "relation_property_id": "mxp^", - "function": "count" + "function": "count_all" } }, "Store availability": { @@ -322,7 +322,7 @@ func TestFindDatabaseByID(t *testing.T) { RelationPropName: "Meals", RollupPropID: "title", RelationPropID: "mxp^", - Function: "count", + Function: notion.RollupFunctionCountAll, }, }, "Store availability": notion.DatabaseProperty{ diff --git a/database.go b/database.go index 97d2b79..183ca20 100644 --- a/database.go +++ b/database.go @@ -39,14 +39,33 @@ type ( SyncedPropID string `json:"synced_property_id,omitempty"` } RollupMetadata struct { - RelationPropName string `json:"relation_property_name,omitempty"` - RelationPropID string `json:"relation_property_id,omitempty"` - RollupPropName string `json:"rollup_property_name,omitempty"` - RollupPropID string `json:"rollup_property_id,omitempty"` - Function string `json:"function,omitempty"` + RelationPropName string `json:"relation_property_name,omitempty"` + RelationPropID string `json:"relation_property_id,omitempty"` + RollupPropName string `json:"rollup_property_name,omitempty"` + RollupPropID string `json:"rollup_property_id,omitempty"` + Function RollupFunction `json:"function,omitempty"` } ) +type RollupFunction string + +const ( + RollupFunctionCountAll RollupFunction = "count_all" + RollupFunctionCountValues RollupFunction = "count_values" + RollupFunctionCountUniqueValues RollupFunction = "count_unique_values" + RollupFunctionCountEmpty RollupFunction = "count_empty" + RollupFunctionCountNotEmpty RollupFunction = "count_not_empty" + RollupFunctionPercentEmpty RollupFunction = "percent_empty" + RollupFunctionPercentNotEmpty RollupFunction = "percent_not_empty" + RollupFunctionSum RollupFunction = "sum" + RollupFunctionAverage RollupFunction = "average" + RollupFunctionMedian RollupFunction = "median" + RollupFunctionMin RollupFunction = "min" + RollupFunctionMax RollupFunction = "max" + RollupFunctionRange RollupFunction = "range" + RollupFunctionShowOriginal RollupFunction = "show_original" +) + type SelectOptions struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"`