Skip to content
Snippets Groups Projects
Unverified Commit 26c6769e authored by Kyle Doherty's avatar Kyle Doherty
Browse files

Merge branch 'fingerprints-poc' of github.com:metabase/metabase into fingerprints-poc

parents 0d25c1b7 d6f444d7
Branches
Tags embedding-sdk-0.1.29
No related merge requests found
......@@ -2,8 +2,6 @@ import React from 'react'
import Tooltip from 'metabase/components/Tooltip'
import Icon from 'metabase/components/Icon'
import { formatValue } from "metabase/lib/formatting";
const SimpleStat = ({ stat, showDescription }) =>
<div>
<div className="flex align-center">
......@@ -16,7 +14,7 @@ const SimpleStat = ({ stat, showDescription }) =>
</div>
{ /* call toString to ensure that values like true / false show up */ }
<h1 className="my1">
{formatValue(stat.value.toString(), {})}
{stat.value}
</h1>
</div>
......
......@@ -5,36 +5,36 @@ import Histogram from 'metabase/xray/Histogram'
import SimpleStat from 'metabase/xray/SimpleStat'
const Constituent = ({constituent}) =>
<div className="Grid my3 bg-white bordered rounded shadowed">
<div className="Grid-cell Cell--1of3 border-right">
<div className="p4">
<Link
to={`xray/field/${constituent.field.id}/approximate`}
className="text-brand-hover link transition-text"
>
<h2 className="text-bold">{constituent.field.display_name}</h2>
</Link>
<p className="text-measure text-paragraph">{constituent.field.description}</p>
<Link
to={`xray/field/${constituent.field.id}/approximate`}
className="no-decoration"
>
<div className="Grid my3 bg-white bordered rounded shadowed shadow-hover no-decoration">
<div className="Grid-cell Cell--1of3 border-right">
<div className="p4">
<h2 className="text-bold text-brand">{constituent.field.display_name}</h2>
<p className="text-measure text-paragraph">{constituent.field.description}</p>
<div className="flex align-center">
{ constituent.min && (
<SimpleStat
stat={constituent.min}
/>
)}
{ constituent.max && (
<SimpleStat
stat={constituent.max}
/>
)}
<div className="flex align-center">
{ constituent.min && (
<SimpleStat
stat={constituent.min}
/>
)}
{ constituent.max && (
<SimpleStat
stat={constituent.max}
/>
)}
</div>
</div>
</div>
</div>
<div className="Grid-cell p3">
<div style={{ height: 220 }}>
<Histogram histogram={constituent.histogram.value} />
<div className="Grid-cell p3">
<div style={{ height: 220 }}>
{ constituent.histogram && (<Histogram histogram={constituent.histogram.value} />) }
</div>
</div>
</div>
</div>
</Link>
export default Constituent
......@@ -15,7 +15,7 @@ const CostSelect = ({ currentCost, onChange }) =>
key={cost}
onClick={() => onChange(cost)}
className={cx(
"flex align-center justify-center cursor-pointer bg-brand-hover text-white-hover transition-background transition-text",
"flex align-center justify-center cursor-pointer bg-brand-hover text-white-hover transition-background transition-text text-grey-2",
{ 'bg-brand text-white': currentCost === cost }
)}
>
......
......@@ -12,7 +12,7 @@ const StatGroup = ({ heading, fingerprint, stats, showDescriptions }) =>
<div className="bordered rounded shadowed bg-white">
<ol className="Grid Grid--1of4">
{ stats.map(stat =>
fingerprint[stat] && (
!!fingerprint[stat] && (
<li className="Grid-cell lg-p3 lg-px4 border-right border-bottom" key={stat}>
<SimpleStat
stat={fingerprint[stat]}
......
......@@ -18,6 +18,7 @@ import {
VALUES_OVERVIEW
} from 'metabase/xray/stats'
import Icon from 'metabase/components/Icon'
import LoadingAndErrorWrapper from 'metabase/components/LoadingAndErrorWrapper'
import CostSelect from 'metabase/xray/components/CostSelect'
import StatGroup from 'metabase/xray/components/StatGroup'
......@@ -105,12 +106,15 @@ class FieldXRay extends Component {
<div className="my4 flex align-center">
<div>
<Link
className="my2 text-bold text-brand-hover inline-block bordered bg-white p1 h4 no-decoration"
className="my2 text-bold text-brand-hover inline-block bordered bg-white p1 h4 no-decoration rounded shadowed"
to={`/xray/table/${fingerprint.table.id}/approximate`}
>
{fingerprint.table.display_name}
<div className="flex align-center">
<Icon name="chevronleft" />
{fingerprint.table.display_name}
</div>
</Link>
<h1 className="m0">
<h1 className="mt2">
{fingerprint.field.display_name} XRay
</h1>
<p className="mt0 text-paragraph text-measure">
......@@ -118,7 +122,7 @@ class FieldXRay extends Component {
</p>
</div>
<div className="ml-auto flex align-center">
<h3 className="mr2">Fidelity:</h3>
<h3 className="mr2 text-grey-3">Fidelity</h3>
<CostSelect
currentCost={params.cost}
onChange={this.changeCost}
......
......@@ -3,6 +3,8 @@ import React, { Component } from 'react'
import { connect } from 'react-redux'
import title from 'metabase/hoc/Title'
import { Link } from 'react-router'
import LoadingAndErrorWrapper from 'metabase/components/LoadingAndErrorWrapper'
import { XRayPageWrapper } from 'metabase/xray/components/XRayLayout'
import {
......@@ -10,10 +12,7 @@ import {
changeCost
} from 'metabase/reference/reference'
import { Link } from 'react-router'
import Histogram from 'metabase/xray/Histogram'
import SimpleStat from 'metabase/xray/SimpleStat'
import Icon from 'metabase/components/Icon'
import COSTS from 'metabase/xray/costs'
import CostSelect from 'metabase/xray/components/CostSelect'
......@@ -22,6 +21,8 @@ import {
getSegmentFingerprint
} from 'metabase/reference/selectors'
import Constituent from 'metabase/xray/components/Constituent'
type Props = {
fetchSegmentFingerPrint: () => void,
fingerprint: {}
......@@ -38,7 +39,7 @@ const mapDispatchToProps = {
}
@connect(mapStateToProps, mapDispatchToProps)
@title(({ fingerprint }) => fingerprint.segment && fingerprint.segment.display_name || "Segment" )
@title(({ fingerprint }) => fingerprint && fingerprint.segment.name || "Segment" )
class SegmentXRay extends Component {
props: Props
......@@ -61,7 +62,7 @@ class SegmentXRay extends Component {
changeCost = (cost) => {
const { params } = this.props
// TODO - this feels kinda icky, would be nice to be able to just pass cost
this.props.changeCost(`table/${params.segmentId}/${cost}`)
this.props.changeCost(`segment/${params.segmentId}/${cost}`)
}
render () {
......@@ -75,52 +76,40 @@ class SegmentXRay extends Component {
{ () =>
<div className="full">
<div className="my4 flex align-center py2">
<h1>{ fingerprint.segment.display_name }</h1>
<div>
<Link
className="my2 text-bold text-brand-hover inline-block bordered bg-white p1 h4 no-decoration shadowed rounded"
to={`/xray/table/${fingerprint.table.id}/approximate`}
>
<div className="flex align-center">
<Icon name="chevronleft" />
{fingerprint.table.display_name}
</div>
</Link>
<h1>{ fingerprint.segment.name } XRay</h1>
<p className="m0 text-paragraph text-measure">
{fingerprint.segment.description}
</p>
</div>
<div className="ml-auto flex align-center">
<h3 className="mr2">Fidelity:</h3>
<h3 className="mr2 text-grey-3">Fidelity</h3>
<CostSelect
currentCost={params.cost}
onChange={this.changeCost}
/>
</div>
<ol>
{ constituents.map(c => {
return (
<li className="Grid my3 bg-white bordered rounded shadowed">
<div className="Grid-cell Cell--1of3 border-right">
<div className="p4">
<Link
to={`xray/field/${c.field.id}/approximate`}
className="text-brand-hover link transition-text"
>
<h2 className="text-bold">{c.field.display_name}</h2>
</Link>
<p className="text-measure text-paragraph">{c.field.description}</p>
<div className="flex align-center">
{ c.min && (
<SimpleStat
stat={c.min}
/>
)}
{ c.max && (
<SimpleStat
stat={c.max}
/>
)}
</div>
</div>
</div>
<div className="Grid-cell p3">
<div style={{ height: 220 }}>
<Histogram histogram={c.histogram.value} />
</div>
</div>
</li>
)
})}
</ol>
</div>
<ol>
{ constituents.map(c => {
return (
<li>
<Constituent
constituent={c}
/>
</li>
)
})}
</ol>
</div>
}
</LoadingAndErrorWrapper>
......
......@@ -26,11 +26,12 @@
"Transuce each column in given dataset with corresponding fingerprinter."
[opts {:keys [rows cols]}]
(transduce identity
(apply redux/juxt (map-indexed (fn [i field]
(redux/pre-step
(f/fingerprinter opts field)
#(nth % i)))
cols))
(->> cols
(remove :remapped_from)
(map-indexed (fn [i field]
(redux/pre-step (f/fingerprinter opts field)
#(nth % i))))
(apply redux/juxt))
rows))
(defmulti
......
......@@ -34,7 +34,7 @@
:var {:label "Variance"
:description "Measure of how far the values are spread from the mean."
:link "https://en.wikipedia.org/wiki/Variance"}
:sd {:label "Standard deviatin"
:sd {:label "Standard deviation"
:description "Measure of how far the values are spread from the mean."
:link "https://en.wikipedia.org/wiki/Standard_deviation"}
:count {:label "Count"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment