-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adds sortable table detail page #691
Conversation
f05dce2
to
b8e9a7c
Compare
@@ -8,8 +8,14 @@ import { UpIcon, DownIcon } from '../SVGIcons'; | |||
|
|||
import './styles.scss'; | |||
|
|||
type TextAlignmentValues = 'left' | 'right' | 'center'; | |||
// export type SortDirection = 'asc' | 'desc'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will implement it shortly!
@@ -153,17 +197,26 @@ const ColumnList: React.FC<ColumnListProps> = ({ | |||
name: item.name, | |||
database, | |||
}, | |||
usage: hasItemStats ? item.stats[0].stat_val : '', | |||
sort_order: item.sort_order, | |||
usage: hasItemStats ? +item.stats[0].stat_val : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the api guarantees the column usage will be the first statistic, so perhaps we should have a helper method to intentionally search for the column_usage
statistic and extract the value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
Right now this will work, but as we add more stats it will definitely break.
I will add something now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, currently we have single stat at Lyft, but we will ingest more stat later. I think we should either define the query / metric name in config for sorting or redefine the usage not part of stat. I wonder whether we could choose the former?
isEditable: item.is_editable, | ||
editText, | ||
editUrl, | ||
index, | ||
}; | ||
}); | ||
const statsCount = formattedData.filter((item) => !!item.stats).length; | ||
const hasStats = statsCount >= SHOW_STATS_THRESHOLD; | ||
const hasStats = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is this more accurately hasUsage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will change
Looks like tests are failing because of amundsencommon? cc @allisonsuarez since I think you were working on it. On my end only concern is my comment about reliable logic to extract the column usage from the stats. |
let me take a look at the code as well. I was raising a question: could we sort based on a metric which defined by usage? We name column usage but other OSS could name it differently. Also is @ttannis 's concern extracting column usage in stats requiring certain hack? do you think if we put query / column usage as separate node helps? |
@@ -76,6 +90,50 @@ type ExpandedRowProps = { | |||
}; | |||
|
|||
const SHOW_STATS_THRESHOLD = 1; | |||
const USAGE_STAT_TYPE = 'column_usage'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be the item to move to the config, however I am wary of creating that abstraction now, without knowing more about what it is to come.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a todo for moving it to config as follow up as column_usage
is just a stat name used internally for query usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand that. I am alright with it as it since the community will be able to follow existing examples to make this more flexible if/when needed.
@@ -76,6 +90,50 @@ type ExpandedRowProps = { | |||
}; | |||
|
|||
const SHOW_STATS_THRESHOLD = 1; | |||
const USAGE_STAT_TYPE = 'column_usage'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a todo for moving it to config as follow up as column_usage
is just a stat name used internally for query usage?
: stringSortingFunction; | ||
}; | ||
|
||
const getUsageStat = (item) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems sometimes we have type for input and sometimes not?
isEditable: item.is_editable, | ||
editText, | ||
editUrl, | ||
index, | ||
}; | ||
}); | ||
const statsCount = formattedData.filter((item) => !!item.stats).length; | ||
const hasStats = statsCount >= SHOW_STATS_THRESHOLD; | ||
const hasUsageStat = | ||
getTableSortCriterias().usage && statsCount >= SHOW_STATS_THRESHOLD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if the column has 0 usage, it won't show stat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no element on the data has usage, we won't show the whole column, right.
name: 'Alphabetical', | ||
key: 'name', | ||
direction: SortDirection.descending, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we want to sort the column based on column usage, are we going to add new criteria at here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that change is on the private repo, only for us right now.
I wouldn't call it a hack, rather extra logic to explicitly search the stats array for In short, no strong opinion on changing it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending passing CI checks.
Done! |
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
ab2a628
to
467a79a
Compare
Summary of Changes
Adds ability to sort the table columns on the Table detail page
Tests
Added tests
CheckList
Make sure you have checked all steps below to ensure a timely review.