code: def get_facet_size(self):
      facet_size = self.ds.setting("default_facet_size")
      max_returned_rows = self.ds.setting("max_returned_rows")
      table_facet_size = None
      if self.table:
          tables_metadata = (
              self.ds.metadata("tables", database=self.database) or {}
          )
          table_metadata = tables_metadata.get(self.table) or {}
          if table_metadata:
              table_facet_size = table_metadata.get("facet_size")
      custom_facet_size = self.request.args.get("_facet_size")
      if custom_facet_size:
          if custom_facet_size == "max":
              facet_size = max_returned_rows
          elif custom_facet_size.isdigit():
              facet_size = int(custom_facet_size)
          else:
              # Invalid value, ignore it
              custom_facet_size = None
      if table_facet_size and not custom_facet_size:
          if table_facet_size == "max":
              facet_size = max_returned_rows
          else:
              facet_size = table_facet_size
      return min(facet_size, max_returned_rows)
  
file_path: datasette/datasette/facets.py
imports: import json
  import urllib
  from datasette import hookimpl
  from datasette.database import QueryInterrupted
  from datasette.utils import escape_sqlite, path_with_added_args, path_with_removed_args, detect_json1, sqlite3
label_desc: Use image node_id 4 for calling the Facet obj's underlying member method code with example usage: obj.get_facet_size() and returns: min