-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # Signum.React.Extensions/Dashboard/View/ValueUserQueryListPart.tsx # Signum.React/Scripts/Frames/FramePage.tsx
- Loading branch information
Showing
69 changed files
with
2,458 additions
and
984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
641293c
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.
Presenting CachedQueries
About a month ago we presented the possibility of making the different widgets in a
Dashboard
interact with each other usingInteractionGroups
.But if static dashboards could already be quite demanding for the database, interactive dashboards are even worst... clicking on the different chart elements is addictive!
The solution to this problem is to cache the result of all the queries in the dashboard, save them in files, and let the dashboard use this cached data.... easy.
How to use it
1. Enable caching in your dashboard.
In your dashboard there is a new option
Cache query configuration
when you add this option, there are a few new values to configure:
2. Select which queries to cache.
Once you have activated "Cache query configuration", most of the widgets will have one (or many) new check boxes to enable caching data.
Choose queries with globally visible information: IMPORTANT: Cached queries do not respect TypeConditions!!.
Also choose queries that won't result in huge number of rows (prioritize group by with aggregates).
Pagination works, but gets disabled when
InteractionGroups
are involved (See How it works below).3. Configure when to regenerate cached queries.
There are three options
DashboardEntity
implementesITaskEntity
so you just need to override the implementations ofSchduledTaskEntity
andScheduledTaskLogEntity
in yourStarter.cs
. This is the recommenced way of updating heavyweight dashboards when no one is using the application (during the night).4. Enjoy your dashboard while your DB Rests.
No queries!! And check the
"29 minutes ago"
indicator on the top indicating the user that he is viewing potentially outdated data.How it works
I typically don't get into too much details of how things work, but in this case I think is necessary to have an understanding of the inner workings to build cached dashboards that wont create huge queries that will take too long to execute and download.
There are two parts working together, the server side and the client side:
The server side
The server side will be responsible to save JSON files to the File System / Azure blob storage / etc.. each file contains an object with:
In order to generate this files, the following steps are followed:
Regenerate cached queries
is executed on aDashboard
, each part will translate hisUserQueryEntity
orUserChartEntity
to aQueryRequest
, like a server-sideFindOptions
with filters, columns, orders and pagination.Simplified example:
InteractionGroup
could affect each other, that's why the keys columns (not aggregates) of one query need to be added as column in all the other queries in the same group, so the results can be filtered later. This is the essence of an OLAP cube!Assuming that both UserCharts belong to the same UserGroup, they will generalize like this:
Check the result
You can check the results of all this transformations by clicking in the Cheched Queries counter inside
Cached Query Configuration
:There you can see how many queries are made, each with the number of columns and rows, how long took the query and uploading the file and for how many user assets it will be re-used.
You can also check the content itself by opening the
CachedQueryEntity
.If you click in
Format JSON
you can see that theResultTable
format has been optimized to avoid duplicating big values, likeLite<T>
or dates, that are repeated in many rows.The client side
When the Dasboard is loaded, the response contains together with the
DashboardEntity
, a list ofCachedQueryEntity
with theFilePathEmbedded
to download the files. Each file will be downloaded only once even if used by many widgets.Now
UserQueryPart.tsx
,ValueUserQueryListPart.tsx
andUserChartPart.tsx
have been extended to implement some new extension points inSearchControl
,ValueSearchControl
, etc..This allows custom code to be used to resolve the
QueryRequest
in aResultTable
without calling the server API that makes a DB query.In this case, the custom code will do the filtering, grouping, column selection, ordering and pagination, all locally in JavaScript in the client machine, liberating the web server of any work.
I've tried to make this code fast using simple loops, some
eval
tricks and doing strict equality (===
) but maybe someone comes with better ideas. If you want to take a look how this work, check here.Mixing cached and non-cached information
I'm very happy with the current solution's ability to mix and match cached and non-cached data in the same dashboard.
For example you can have some global widgets with
"Sales by month"
or"Top producs"
of the company visible to all the users cached, but have a "My Orders" search control that is non cached because doing it will be inefficient and TypeConditions don't work in cached queries!.You can even have them in the same
InteractionGroup
, so you click in one on the"Top producs"
and it filters the orders that contains this products inMy Orders
.And of course you can open one char's data by
Alt+Click
on a chart's element. This will make a DB query (very concrete filters and different columns) so some inconsistencies should be expected.Conclusion
Dashboards are getting quite more powerful and scalable!
Let's see what else we can do in the future :)
641293c
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.
Excellent improvement! Great! 👌 👏
Thanks 🙏
641293c
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.