@@ -93,7 +93,7 @@ def add_row(data)
93
93
properties [ col_map [ col . to_s ] ] = [ [ data [ col ] ] ]
94
94
end
95
95
96
- collection_data [ "block" ] [ collection_row . id ] = { "role" => "editor" , "value" => { "id" => collection_row . id , "version" => 12 , "type" => "page" , "properties" => properties , "created_time" => 1607253360000 , "last_edited_time" => 1607253360000 , "parent_id" => "dde513c6-2428-4a5d-a830-7a67fdbf6b48" , "parent_table" => "collection" , "alive" => true , "created_by_table" => "notion_user" , "created_by_id" => "0c5f02f3-495d-4b73-b1c5-9f6fe03a8c26" , "last_edited_by_table" => "notion_user" , "last_edited_by_id" => "0c5f02f3-495d-4b73-b1c5-9f6fe03a8c26" , "shard_id" => 955090 , "space_id" => "f687f7de-7f4c-4a86-b109-941a8dae92d2" } }
96
+ collection_data [ "block" ] [ collection_row . id ] = { "role" => "editor" , "value" => { "id" => collection_row . id , "version" => 12 , "type" => "page" , "properties" => properties , "created_time" => 1607253360000 , "last_edited_time" => 1607253360000 , "parent_id" => "dde513c6-2428-4a5d-a830-7a67fdbf6b48" , "parent_table" => "collection" , "alive" => true , "created_by_table" => "notion_user" , "created_by_id" => "0c5f02f3-495d-4b73-b1c5-9f6fe03a8c26" , "last_edited_by_table" => "notion_user" , "last_edited_by_id" => "0c5f02f3-495d-4b73-b1c5-9f6fe03a8c26" , "shard_id" => 955090 , "space_id" => "f687f7de-7f4c-4a86-b109-941a8dae92d2" } }
97
97
row_data = collection_data [ "block" ] [ collection_row . id ]
98
98
create_singleton_methods_and_instance_variables ( collection_row , row_data )
99
99
@@ -242,7 +242,7 @@ def create_singleton_methods_and_instance_variables(row, row_data)
242
242
column_hash . keys . each_with_index do |column , i |
243
243
# loop over the column names...
244
244
# set instance variables for each column, allowing the dev to 'read' the column value
245
- cleaned_column = column_hash [ column ] . split ( " " ) . join ( "_" ) . downcase . to_sym
245
+ cleaned_column = clean_property_names ( column_hash , column )
246
246
247
247
# p row_data["value"]["properties"][column_mappings[i]], !(row_data["value"]["properties"][column] or row_data["value"]["properties"][column_mappings[i]])
248
248
if row_data [ "value" ] [ "properties" ] . nil? or row_data [ "value" ] [ "properties" ] [ column ] . nil?
@@ -262,9 +262,7 @@ def create_singleton_methods_and_instance_variables(row, row_data)
262
262
parsed_method = __method__ . to_s [ 0 ...-1 ] . split ( "_" ) . join ( " " )
263
263
cookies = Core . options [ "cookies" ]
264
264
headers = Core . options [ "headers" ]
265
-
266
- p new_value , column_hash . key ( parsed_method ) , column_names , schema
267
-
265
+
268
266
request_id = extract_id ( SecureRandom . hex ( 16 ) )
269
267
transaction_id = extract_id ( SecureRandom . hex ( 16 ) )
270
268
space_id = extract_id ( SecureRandom . hex ( 16 ) )
@@ -282,7 +280,6 @@ def create_singleton_methods_and_instance_variables(row, row_data)
282
280
]
283
281
284
282
if %q[select multi_select] . include? ( schema [ column_hash . key ( parsed_method ) ] [ "type" ] )
285
- p "ENTERED THE ABYSS"
286
283
options = schema [ column_hash . key ( parsed_method ) ] [ "options" ] . nil? ? [ ] : schema [ column_hash . key ( parsed_method ) ] [ "options" ] . map { |option | option [ "value" ] }
287
284
multi_select_multi_options = new_value . split ( "," )
288
285
multi_select_multi_options . each do |option |
@@ -310,6 +307,15 @@ def create_singleton_methods_and_instance_variables(row, row_data)
310
307
end
311
308
end
312
309
end
310
+
311
+ def clean_property_names ( prop_hash , prop_notion_name )
312
+ # ! standardize property names by splitting the words in the property name into an array, removing non-alphanumeric
313
+ # ! characters, downcasing, and then re-joining the array with underscores.
314
+ # ! prop_hash -> hash of property notion names and property textual names: ``str``
315
+ # ! prop_notion_name -> the four-character long name of the notion property: ``str``
316
+
317
+ prop_hash [ prop_notion_name ] . split ( " " ) . map { |word | word . gsub ( /[^a-z0-9]/i , "" ) . downcase } . join ( "_" ) . to_sym
318
+ end
313
319
end
314
320
315
321
# class that represents each row in a CollectionView
0 commit comments