michael-s-molina opened a new pull request #17536:
URL: https://github.com/apache/superset/pull/17536


   ### SUMMARY
   Currently, the filters state is being stored in the URL to allow users to 
preserve their current interactions in case of a refresh and also to share 
specific states with other users. The most common example is when a user, after 
exploring a dashboard using filters, wishes to share their findings with other 
users. 
   
   The problem with this approach is that when the size of the state is big, it 
provokes URL length problems with the major browsers. 
   
   The proposed solution in this PR is to store the filters state on the 
server-side and keep in the URL only a secure key that gives access to the 
stored content. To do that, we'll extend the current dashboard endpoint with an 
additional path that supports the storage of information in the form of 
key-value entries. By making this endpoint relative to the main resource we can 
reuse the security model and access grants.
   
   The additional endpoint and the supported operations are:
   
   ```jsx
   POST api/v1/dashboard/<id>/filters_state
   
   BODY 
   {
      // Any type of JSON supported text.
      value: <string>,
   }
   
   RESPONSE
   {
      // The key generated on the server-side
      key: <string>
   }
   ```
   
   ```jsx
   PUT api/v1/dashboard/<id>/filters_state/<key>
   
   BODY
   {
      // Any type of JSON supported text.
      value: <string>,
   }
   
   RESPONSE
   {
      // The result of the operation
      message: <string>
   }
   ```
   
   ```jsx
   GET api/v1/dashboard/<id>/filters_state/<key>
   
   RESPONSE
   {
      // Any type of JSON supported text.
      value: <string>,
   }
   ```
   
   ```jsx
   DELETE api/v1/dashboard/<id>/filters_state/<key>
   
   RESPONSE
   {
      // The result of the operation
      message: <string>
   }
   ```
   
   The keys are generated on the server-side using the 
https://docs.python.org/3/library/secrets.html#secrets.token_urlsafe function 
and the value can be any JSON supported text.
   
   To store the key-value entries, this PR uses 
[Flask-Caching](https://flask-caching.readthedocs.io/en/latest/), which enables 
support to different backends like [Redis](https://redis.io/), 
[Memcached](https://memcached.org/), file system, etc. It also allows the 
configuration of expiration times for the stored entries in order to discard 
the ones that are not being used anymore and optimize the required storage 
space.
   
   This PR also allows a configuration to preserve actively accessed entries by 
renewing the expiration time every time a value is retrieved.
   
   Follow-up of https://github.com/apache/superset/pull/17337
   
   ### TESTING INSTRUCTIONS
   1 - Execute Python tests
   2 - All tests should pass
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to