User training statistics week issue

Created on 12 January 2024, 11 months ago

Problem/Motivation

Recently I found Line 202 of UserStatisticsManager.php. The MySQL WEEK function was used to count user data, and the data was grouped by week. A problem was discovered during use. The MySQL WEEK function defaults to calculating based on Sunday, while PHP date The week number returned by W in format is calculated based on Monday, which may lead to inconsistent data statistics in extreme cases.

Steps to reproduce

Submit a piece of training data on 2024-01-11, whether it is completed or to be completed. At this time, check the TRENDS chart statistics in the User Profile. You will find that Week4 has data, but Week5 has no data. According to the code logic, the valid data should be In Week5

Proposed resolution

Add an additional mode parameter when using the WEEK function in UserStatisticsManager.php line 202. Set the mode to 1 to indicate that the calculation starts on Monday. This ensures that the MySQL week function calculation is consistent with the PHP date format rules.

https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sys...

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

3.1

Component

Code

Created by

🇨🇳China maoxuan@ciandt.com

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024