Bunbunw opened a new pull request, #36315:
URL: https://github.com/apache/superset/pull/36315

   ### SUMMARY
   This is a fix related to 
[issue#21870](https://github.com/apache/superset/issues/21870).
   
   Unexpected Behaviour: In calendar heatmap, when the end date is the start 
day of the month, an extra null month is rendered, the null month is either 
rendered before or after based on local time offset compared to UTC.
   Expected Behaviour: When rendering date, if first day of a month is selected 
as the end date, default going to 12AM, the month containing this date should 
not be rendered.
   ### IMPLEMENTATION DETAILS FOR REFERENCE
   Modified logic related to plugin calendar-heatmap month-day rendering 
behaviour:
   - cal-heatmaps.js contains a function named “getMonthDomain” responsible for 
returning time range for frontend render, replacing javascript Date methods 
with UTC equivalent to remove local time zone offset issue. Our rationale for 
this change is to preserve consistent time ranges between users in different 
time zones. We noticed our reproduction of the issue resulted in a null month 
prior to the time range of the chart, compared to the issuer’s example. This is 
because our time zone is in EST, which is 4-5 hours behind UTC depending on 
daylight savings. The issuer’s Superset image was in the Dutch language, so we 
assumed CET, an hour ahead of UTC. This is why the null month placement was 
different in our reproduction compared to theirs. 
   - viz.py contains the backend class definition for “CalHeatmapViz”. 
Subtracted 1 day for end, when calculating range for first day of the month, to 
enforce exclusive end date, as desired for Superset’s Calendar Heatmap chart 
definition. This gets rid of null month rendering behaviour.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Setup steps, create a dataset using users:
   
   Before any fix (Based in EST):
   <img width="714" height="497" alt="Screenshot 2025-11-27 at 7 17 37 PM" 
src="https://github.com/user-attachments/assets/5a79f9aa-b963-4791-8f87-cb45907f40ea";
 />
   After adding only UTC functions:
   <img width="714" height="486" alt="Screenshot 2025-11-27 at 7 17 56 PM" 
src="https://github.com/user-attachments/assets/adfbd7a8-c2f0-448f-83bb-c3010f09263d";
 />
   After both UTC and viz.py updates:
   <img width="618" height="562" alt="Screenshot 2025-11-27 at 7 18 17 PM" 
src="https://github.com/user-attachments/assets/99e8196a-283d-4c54-922c-ebd9031f6f53";
 />
   
   
   ### TESTING INSTRUCTIONS
   Testing this is normal usage of superset, for details:
   1. Sync superset repo and start the application on localhost using `docker 
compose up --build` and login localhost.
   2. Take any dataset on your Superset instance with date-value data points 
and open a Calendar Heatmap chart with it. (For the following test cases, our 
examples used superset’s preset dataset main.users with the MIN(# tz_offset) 
metrics)
   3. Check what dates your data points occur.
   4. Here are some cases to attempt:
   a) Original issue case: 1st of a month to 1st of another month 2 months 
away, like March 1st to May 1st.
   <img width="314" height="284" alt="Screenshot 2025-11-27 at 7 18 40 PM" 
src="https://github.com/user-attachments/assets/0738f625-761e-44ba-bb46-0db9fa8124ef";
 />
   
   b) Within same month: when selecting March 1st to March 31st, make sure the 
same month range is possible with no repeat of the null month issue.
   <img width="304" height="255" alt="Screenshot 2025-11-27 at 7 20 04 PM" 
src="https://github.com/user-attachments/assets/1f68c53c-366f-4f2e-8ec7-08285dd23864";
 />
   
   c) >1 year case: like January 1st to January 1st of subsequent year, to make 
sure a range with years considered is displaying correctly.
   <img width="523" height="273" alt="Screenshot 2025-11-27 at 7 20 13 PM" 
src="https://github.com/user-attachments/assets/db87fec0-d5ef-44b4-b260-c84aa22ffb86";
 />
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: this pr is only related to and fixes #21870
   - [ ] Required feature flags:
   - [x] 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
   - [ ] 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