コード例 #1
0
ファイル: views.py プロジェクト: Altiscale/hue
def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_type):
  properties = {
    'sort': 'desc',
    'canRange': False,
    'stacked': False,
    'limit': 10,
    'mincount': 0,
    'isDate': False,
    'andUp': False,  # Not used yet
  }

  solr_api = SolrApi(SOLR_URL.get(), user)
  range_properties = _new_range_facet(solr_api, collection, facet_field, widget_type)

  if range_properties:
    facet_type = 'range'
    properties.update(range_properties)
  elif widget_type == 'hit-widget':
    facet_type = 'query'
  else:
    facet_type = 'field'

  if widget_type == 'map-widget':
    properties['scope'] = 'world'
    properties['mincount'] = 1
    properties['limit'] = 100

  return {
    'id': facet_id,
    'label': facet_label,
    'field': facet_field,
    'type': facet_type,
    'widgetType': widget_type,
    'properties': properties
  }
コード例 #2
0
ファイル: views.py プロジェクト: QLGu/hue
def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_type):
  properties = {
    'sort': 'desc',
    'canRange': False,
    'stacked': False,
    'limit': 10,
    'mincount': 0,
    'isDate': False,
    'aggregate': 'unique'
  }

  if widget_type in ('tree-widget', 'heatmap-widget', 'map-widget'):
    facet_type = 'pivot'
  elif widget_type == 'hit-widget':
    facet_type = 'function'
  else:
    solr_api = SolrApi(SOLR_URL.get(), user)
    range_properties = _new_range_facet(solr_api, collection, facet_field, widget_type)

    if range_properties:
      facet_type = 'range'
      properties.update(range_properties)
      properties['initial_gap'] = properties['gap']
      properties['initial_start'] = properties['start']
      properties['initial_end'] = properties['end']
    else:
      facet_type = 'field'

    if widget_type == 'bucket-widget':
      facet_type = 'nested'
      properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 10, 'aggregate': 'count'}
      properties['facets'] = []
      properties['scope'] = 'stack'
      properties['timelineChartType'] = 'bar'

  if widget_type in ('tree-widget', 'heatmap-widget', 'map-widget'):
    properties['mincount'] = 1
    properties['facets'] = []
    properties['stacked'] = True
    properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 5}

    if widget_type == 'map-widget':
      properties['scope'] = 'world'
      properties['limit'] = 100
    else:
      properties['scope'] = 'stack' if widget_type == 'heatmap-widget' else 'tree'

  return {
    'id': facet_id,
    'label': facet_label,
    'field': facet_field,
    'type': facet_type,
    'widgetType': widget_type,
    'properties': properties
  }
コード例 #3
0
def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_type):
  properties = {
    'sort': 'desc',
    'canRange': False,
    'stacked': False,
    'limit': 10,
    'mincount': 0,
    'isDate': False,
    'aggregate': 'unique'
  }

  if widget_type in ('tree-widget', 'heatmap-widget', 'map-widget'):
    facet_type = 'pivot'
  elif widget_type == 'hit-widget':
    facet_type = 'function'
  else:
    solr_api = SolrApi(SOLR_URL.get(), user)
    range_properties = _new_range_facet(solr_api, collection, facet_field, widget_type)

    if range_properties:
      facet_type = 'range'
      properties.update(range_properties)
      properties['initial_gap'] = properties['gap']
      properties['initial_start'] = properties['start']
      properties['initial_end'] = properties['end']
    else:
      facet_type = 'field'

    if widget_type == 'bucket-widget':
      facet_type = 'nested'
      properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 10, 'aggregate': 'count'}
      properties['facets'] = []
      properties['scope'] = 'stack'
      properties['timelineChartType'] = 'bar'

  if widget_type in ('tree-widget', 'heatmap-widget', 'map-widget'):
    properties['mincount'] = 1
    properties['facets'] = []
    properties['stacked'] = True
    properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 5}

    if widget_type == 'map-widget':
      properties['scope'] = 'world'
      properties['limit'] = 100
    else:
      properties['scope'] = 'stack' if widget_type == 'heatmap-widget' else 'tree'

  return {
    'id': facet_id,
    'label': facet_label,
    'field': facet_field,
    'type': facet_type,
    'widgetType': widget_type,
    'properties': properties
  }
コード例 #4
0
ファイル: views.py プロジェクト: suhassatish/hue-mapr
def _create_facet(collection, user, facet_id, facet_label, facet_field,
                  widget_type):
    properties = {
        'sort': 'desc',
        'canRange': False,
        'stacked': False,
        'limit': 10,
        'mincount': 0,
        'isDate': False,
        'andUp': False,  # Not used yet
    }

    if widget_type in ('tree-widget', 'heatmap-widget'):
        facet_type = 'pivot'
    else:
        solr_api = SolrApi(SOLR_URL.get(), user)
        range_properties = _new_range_facet(solr_api, collection, facet_field,
                                            widget_type)

        if range_properties:
            facet_type = 'range'
            properties.update(range_properties)
            properties['initial_gap'] = properties['gap']
        elif widget_type == 'hit-widget':
            facet_type = 'query'
        else:
            facet_type = 'field'

    if widget_type == 'map-widget':
        properties['scope'] = 'world'
        properties['mincount'] = 1
        properties['limit'] = 100
    elif widget_type in ('tree-widget', 'heatmap-widget'):
        properties['mincount'] = 1
        properties['facets'] = []
        properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 5}
        properties[
            'scope'] = 'stack' if widget_type == 'heatmap-widget' else 'tree'

    return {
        'id': facet_id,
        'label': facet_label,
        'field': facet_field,
        'type': facet_type,
        'widgetType': widget_type,
        'properties': properties
    }
コード例 #5
0
ファイル: views.py プロジェクト: Hojat-dashboard/hue
def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_type):
  properties = {
    'sort': 'desc',
    'canRange': False,
    'stacked': False,
    'limit': 10,
    'mincount': 0,
    'isDate': False,
    'andUp': False,  # Not used yet
  }

  if widget_type in ('tree-widget', 'heatmap-widget'):
    facet_type = 'pivot'
  else:
    solr_api = SolrApi(SOLR_URL.get(), user)
    range_properties = _new_range_facet(solr_api, collection, facet_field, widget_type)

    if range_properties:
      facet_type = 'range'
      properties.update(range_properties)
      properties['initial_gap'] = properties['gap']
    elif widget_type == 'hit-widget':
      facet_type = 'query'
    else:
      facet_type = 'field'

  if widget_type == 'map-widget':
    properties['scope'] = 'world'
    properties['mincount'] = 1
    properties['limit'] = 100
  elif widget_type in ('tree-widget', 'heatmap-widget'):
    properties['mincount'] = 1
    properties['facets'] = []
    properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 5}
    properties['scope'] = 'stack' if widget_type == 'heatmap-widget' else 'tree'

  return {
    'id': facet_id,
    'label': facet_label,
    'field': facet_field,
    'type': facet_type,
    'widgetType': widget_type,
    'properties': properties
  }
コード例 #6
0
ファイル: views.py プロジェクト: tp0101/hue
def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_type):
    properties = {
        "sort": "desc",
        "canRange": False,
        "stacked": False,
        "limit": 10,
        "mincount": 0,
        "isDate": False,
        "andUp": False,  # Not used yet
    }

    if widget_type == "tree-widget":
        facet_type = "pivot"
    else:
        solr_api = SolrApi(SOLR_URL.get(), user)
        range_properties = _new_range_facet(solr_api, collection, facet_field, widget_type)

        if range_properties:
            facet_type = "range"
            properties.update(range_properties)
        elif widget_type == "hit-widget":
            facet_type = "query"
        else:
            facet_type = "field"

    if widget_type == "map-widget":
        properties["scope"] = "world"
        properties["mincount"] = 1
        properties["limit"] = 100
    elif widget_type == "tree-widget":
        properties["mincount"] = 1
        properties["facets"] = []
        properties["facets_form"] = {"field": "", "mincount": 1, "limit": 10}
        properties["graph"] = False

    return {
        "id": facet_id,
        "label": facet_label,
        "field": facet_field,
        "type": facet_type,
        "widgetType": widget_type,
        "properties": properties,
    }
コード例 #7
0
ファイル: views.py プロジェクト: onimsha/hue
def _create_facet(collection, user, facet_id, facet_label, facet_field,
                  widget_type):
    properties = {
        'sort': 'desc',
        'canRange': False,
        'stacked': False,
        'limit': 10,
        'mincount': 0,
        'isDate': False,
        'andUp': False,  # Not used yet
    }

    solr_api = SolrApi(SOLR_URL.get(), user)
    range_properties = _new_range_facet(solr_api, collection, facet_field,
                                        widget_type)

    if range_properties:
        facet_type = 'range'
        properties.update(range_properties)
    elif widget_type == 'hit-widget':
        facet_type = 'query'
    else:
        facet_type = 'field'

    if widget_type == 'map-widget':
        properties['scope'] = 'world'
        properties['mincount'] = 1
        properties['limit'] = 100

    return {
        'id': facet_id,
        'label': facet_label,
        'field': facet_field,
        'type': facet_type,
        'widgetType': widget_type,
        'properties': properties
    }
コード例 #8
0
ファイル: views.py プロジェクト: cloudera/hue
def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_type):
    properties = {
        "sort": "desc",
        "canRange": False,
        "stacked": False,
        "limit": 10,
        "mincount": 0,
        "isDate": False,
        "aggregate": {"function": "unique", "ops": [], "percentiles": [{"value": 50}]},
    }

    if widget_type in ("tree-widget", "heatmap-widget", "map-widget"):
        facet_type = "pivot"
    elif widget_type == "gradient-map-widget":
        facet_type = "nested"
        properties["facets"] = []
        properties["domain"] = {"blockParent": [], "blockChildren": []}
        properties["facets_form"] = {
            "field": "",
            "mincount": 1,
            "limit": 10,
            "aggregate": {"function": "unique", "ops": [], "percentiles": [{"value": 50}]},
        }
        properties["scope"] = "world"
        properties["limit"] = 100
    else:
        solr_api = SolrApi(SOLR_URL.get(), user)
        range_properties = _new_range_facet(solr_api, collection, facet_field, widget_type)

        if range_properties:
            facet_type = "range"
            properties.update(range_properties)
            properties["initial_gap"] = properties["gap"]
            properties["initial_start"] = properties["start"]
            properties["initial_end"] = properties["end"]
        else:
            facet_type = "field"

        if widget_type in (
            "bucket-widget",
            "pie2-widget",
            "timeline-widget",
            "tree2-widget",
            "text-facet-widget",
            "hit-widget",
        ):
            if widget_type == "text-facet-widget":
                properties["type"] = facet_type
            if widget_type == "hit-widget":
                facet_type = "function"
            else:
                facet_type = "nested"
            properties["facets_form"] = {
                "field": "",
                "mincount": 1,
                "limit": 10,
                "aggregate": {"function": "unique", "ops": [], "percentiles": [{"value": 50}]},
            }
            properties["facets"] = []
            properties["domain"] = {"blockParent": [], "blockChildren": []}

            if widget_type == "pie2-widget":
                properties["scope"] = "stack"
                properties["timelineChartType"] = "bar"
            elif widget_type == "tree2-widget":
                properties["scope"] = "tree"
                properties["facets_form"]["limit"] = 5
                properties["isOldPivot"] = True
            else:
                properties["scope"] = "stack"
                properties["timelineChartType"] = "bar"

    if widget_type in ("tree-widget", "heatmap-widget", "map-widget"):
        properties["mincount"] = 1
        properties["facets"] = []
        properties["stacked"] = True
        properties["facets_form"] = {"field": "", "mincount": 1, "limit": 5}

        if widget_type == "map-widget":
            properties["scope"] = "world"
            properties["limit"] = 100
        else:
            properties["scope"] = "stack" if widget_type == "heatmap-widget" else "tree"

    return {
        "id": facet_id,
        "label": facet_label,
        "field": facet_field,
        "type": facet_type,
        "widgetType": widget_type,
        "properties": properties,
        # Hue 4+
        "template": {
            "showFieldList": True,
            "showGrid": False,
            "showChart": True,
            "chartSettings": {
                "chartType": "pie"
                if widget_type == "pie2-widget"
                else (
                    "timeline"
                    if widget_type == "timeline-widget"
                    else ("gradientmap" if widget_type == "gradient-map-widget" else "bars")
                ),
                "chartSorting": "none",
                "chartScatterGroup": None,
                "chartScatterSize": None,
                "chartScope": "world",
                "chartX": None,
                "chartYSingle": None,
                "chartYMulti": [],
                "chartData": [],
                "chartMapLabel": None,
            },
            "fieldsAttributes": [],
            "fieldsAttributesFilter": "",
            "filteredAttributeFieldsAll": True,
            "fields": [],
            "fieldsSelected": [],
            "leafletmap": {"latitudeField": None, "longitudeField": None, "labelField": None},  # Use own?
            "leafletmapOn": False,
            "isGridLayout": False,
            "hasDataForChart": True,
            "rows": 25,
        },
    }
コード例 #9
0
ファイル: views.py プロジェクト: victordpg/hue
def _create_facet(collection, user, facet_id, facet_label, facet_field,
                  widget_type):
    properties = {
        'sort': 'desc',
        'canRange': False,
        'stacked': False,
        'limit': 10,
        'mincount': 0,
        'isDate': False,
        'aggregate': {
            'function': 'unique',
            'ops': [],
            'percentiles': [{
                'value': 50
            }]
        }
    }

    if widget_type in ('tree-widget', 'heatmap-widget', 'map-widget'):
        facet_type = 'pivot'
    elif widget_type == 'gradient-map-widget':
        facet_type = 'nested'
        properties['facets'] = []
        properties['domain'] = {'blockParent': [], 'blockChildren': []}
        properties['facets_form'] = {
            'field': '',
            'mincount': 1,
            'limit': 10,
            'aggregate': {
                'function': 'unique',
                'ops': [],
                'percentiles': [{
                    'value': 50
                }]
            }
        }
        properties['scope'] = 'world'
        properties['limit'] = 100
    else:
        solr_api = SolrApi(SOLR_URL.get(), user)
        range_properties = _new_range_facet(solr_api, collection, facet_field,
                                            widget_type)

        if range_properties:
            facet_type = 'range'
            properties.update(range_properties)
            properties['initial_gap'] = properties['gap']
            properties['initial_start'] = properties['start']
            properties['initial_end'] = properties['end']
        else:
            facet_type = 'field'

        if widget_type in ('bucket-widget', 'pie2-widget', 'timeline-widget',
                           'tree2-widget', 'text-facet-widget', 'hit-widget'):
            if widget_type == 'text-facet-widget':
                properties['type'] = facet_type
            if widget_type == 'hit-widget':
                facet_type = 'function'
            else:
                facet_type = 'nested'
            properties['facets_form'] = {
                'field': '',
                'mincount': 1,
                'limit': 10,
                'aggregate': {
                    'function': 'unique',
                    'ops': [],
                    'percentiles': [{
                        'value': 50
                    }]
                }
            }
            properties['facets'] = []
            properties['domain'] = {'blockParent': [], 'blockChildren': []}

            if widget_type == 'pie2-widget':
                properties['scope'] = 'stack'
                properties['timelineChartType'] = 'bar'
            elif widget_type == 'tree2-widget':
                properties['scope'] = 'tree'
                properties['facets_form']['limit'] = 5
                properties['isOldPivot'] = True
            else:
                properties['scope'] = 'stack'
                properties['timelineChartType'] = 'bar'

    if widget_type in ('tree-widget', 'heatmap-widget', 'map-widget'):
        properties['mincount'] = 1
        properties['facets'] = []
        properties['stacked'] = True
        properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 5}

        if widget_type == 'map-widget':
            properties['scope'] = 'world'
            properties['limit'] = 100
        else:
            properties[
                'scope'] = 'stack' if widget_type == 'heatmap-widget' else 'tree'

    return {
        'id': facet_id,
        'label': facet_label,
        'field': facet_field,
        'type': facet_type,
        'widgetType': widget_type,
        'properties': properties,
        # Hue 4+
        'template': {
            "showFieldList": True,
            "showGrid": False,
            "showChart": True,
            "chartSettings": {
                'chartType':
                'pie' if widget_type == 'pie2-widget' else
                ('timeline' if widget_type == 'timeline-widget' else
                 ('gradientmap'
                  if widget_type == 'gradient-map-widget' else 'bars')),
                'chartSorting':
                'none',
                'chartScatterGroup':
                None,
                'chartScatterSize':
                None,
                'chartScope':
                'world',
                'chartX':
                None,
                'chartYSingle':
                None,
                'chartYMulti': [],
                'chartData': [],
                'chartMapLabel':
                None,
            },
            "fieldsAttributes": [],
            "fieldsAttributesFilter": "",
            "filteredAttributeFieldsAll": True,
            "fields": [],
            "fieldsSelected": [],
            "leafletmap": {
                'latitudeField': None,
                'longitudeField': None,
                'labelField': None
            },  # Use own?
            'leafletmapOn': False,
            'isGridLayout': False,
            "hasDataForChart": True,
            "rows": 25,
        }
    }