Skip to content

Commit

Permalink
feat: improve analytics index usage, improve analytics data-grid
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen committed Oct 5, 2023
1 parent 657fea7 commit 07a6452
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
38 changes: 32 additions & 6 deletions front/share/src/analytics/DataGrid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
a.download = `${data.title}.csv`;
a.click();
};
let scrollX = 0;
</script>
<style>
Expand All @@ -79,12 +81,16 @@
border-collapse: collapse;
}
thead {
background: rgba(0, 0, 0, 0.06);
thead > tr > th {
background-color: #f0f0f0;
}
tbody > tr:nth-child(even) > td {
background-color: #f7f7f7;
}
tbody > tr:nth-child(even) {
background: rgba(0, 0, 0, 0.03);
tbody > tr:nth-child(odd) > td {
background-color: #ffffff;
}
th {
Expand Down Expand Up @@ -170,6 +176,26 @@
font-weight: 500;
}
th:first-child, td:first-child {
position: sticky;
z-index: 1;
left: 0;
max-width: min(18rem, 35vw);
overflow-wrap: break-word;
padding-inline-end: 0.5rem;
}
th:first-child > *, td:first-child > * {
max-width: 100%;
}
.scrolled-x th:first-child, .scrolled-x td:first-child {
background-image: linear-gradient(
to right, transparent 0%, transparent calc(100% - 0.75rem), rgba(0,0,0,0.025) 100%
);
}
.export-out {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -197,7 +223,7 @@
</style>
<div class="grid-out">
<div class="grid thin-scroll">
<div class="grid thin-scroll" class:scrolled-x={scrollX !== 0} on:scroll={event => scrollX = event.currentTarget.scrollLeft} >
<table>
<thead>
<tr>
Expand Down Expand Up @@ -264,4 +290,4 @@
{locale.export_as_csv}
</button>
</div>
</div>
</div>
2 changes: 2 additions & 0 deletions rs/packages/db/src/models/stream_connection/analytics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ pub async fn get_analytics(query: AnalyticsQuery) -> Result<Analytics, mongodb::

let sort = doc! {
StreamConnectionLite::KEY_CREATED_AT: 1,
// force index usage { ca: 1, st: 1 }
StreamConnectionLite::KEY_STATION_ID: 1,
};

let options = mongodb::options::FindOptions::builder().sort(sort).build();
Expand Down

0 comments on commit 07a6452

Please sign in to comment.