-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Last Played At: Add UI for last_played_at column #3457
Conversation
@@ -386,15 +386,18 @@ void insertTrack( | |||
query.bindValue(":bitrate", bitrate); | |||
query.bindValue(":analyze_path", anlzPath); | |||
query.bindValue(":device", device); | |||
query.bindValue(":color", mixxx::RgbColor::toQVariant(colorFromID(static_cast<int>(track->color_id())))); | |||
query.bindValue(":color", |
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.
the code formatter went to town on this file.
@@ -1093,6 +1189,9 @@ void RekordboxPlaylistModel::initSortColumnMapping() { | |||
m_columnIndexBySortColumnId[static_cast<int>( | |||
TrackModel::SortColumnId::TimesPlayed)] = | |||
fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED); | |||
m_columnIndexBySortColumnId[static_cast<int>( |
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.
here is the actual new code in this file
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.
Thank you for finishing this feature! Code changes seem sensible, less than expected. Not yet test.
Conflicts. Should be rebased after #3465 has been merged into main. |
Just one minor suggestion for renaming the column header. Otherwise ready to merge. |
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.
The play column has an offset of UTC-Local Time.
In the sqlite file we use UTC to store the date added. That is OK to see a consecutive order independent of the time zones.
The last played column is stored in local time an I think the display code here assumes UTC, leading to the issue.
I am not DJing in different time Zones, but I can imagine that here is a use case of sorting the tracks by hour last played.
If I had a gig China for instance and back in Europa I see the tracks played at 14:00 MET which has been played in China at 22:00 local time, it will be confusing.
lt;dr:
Let's stick with storing local time and remove the offset for displaying here.
src/library/basetracktablemodel.cpp
Outdated
@@ -613,6 +618,7 @@ QVariant BaseTrackTableModel::roleValue( | |||
return QString("(%1)").arg(timesPlayed); | |||
} | |||
case ColumnCache::COLUMN_LIBRARYTABLE_DATETIMEADDED: | |||
case ColumnCache::COLUMN_LIBRARYTABLE_LAST_PLAYED_AT: |
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.
COLUMN_LIBRARYTABLE_LAST_PLAYED_AT is not UTC. We need an extra case here.
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.
@daschuer It actually is stored as UTC, so this code correct. Please double check!
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.
No, not with current upstream/main.
If we decide for UTC in the library, the code her is correct.
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.
We cannot decide about this if the system already decided for us. At least for my setup the timestamps are stored in UTC (see comments).
CURRENT_TIMSTAMP generates an UTC timestamp for me. Please try this |
I think @daschuer meant that we wants to store the local timezone the track was played in, not UTC. Personally I think if you travel a lot, it would be even more confusing if the last time played is ahead of your current local time. Therefore I think storing UTC makes sense and will probably save us a lot of headaches later on. |
This works for me in UTC and is used for time added. It looks like that the "last_played_at" column using local time, which is also OK for me.
It is already stored in local time. The issue her is that the displaying code assumes UTC and does a unnecessary and wrong conversion.
Can this actually happen? How?
Yes, I think storing the value in UTC is reasonable, since all other times are also UTC. This is currently not the case. If we only store UTC without the current Time zone. We can't do time only queries like "Tracks played at dinner timer" 18:00 - 21:00 or such. Because the dinner time in MET is not related to dinner time in CST. A time zone field for each history playlist would be sufficient since it is unlikely that a DJ move the time zone during a gig. |
I disagree. Storing plain UTC is valid and appropriate only for system-level events and as an optimization for sorting/ordering. For user-level events that are often related to a geographical location you need to store local time with the time offset. This allows both, consistent ordering and meaningful display. Without the time offset (representing the time zone) you lose information! This discussion is out of scope. Please report unambiguously what time is actually stored in your database and post an example timestamp. Please remember, for SQLite this is just plain text. |
Yes, it can happen. Random example:
|
|
I suppose the content of pl_datetime_added depends on the system clock. This is unfortunate. |
I am not sure where you disagree to. We have here a bug that the time "last_played_at column" shows the wrong time, that is the root issue. What is your proposal to solve this?
Yes of cause. My considerations are if your did play a DJ gig just before and after start and the user expectationion when looking at a history playlist recorded in a different time zone. But anyway, this would be "feature" of the history playlist. Here we are taking about last_played_at.
In DB: in GUI |
#3477 tries to address the time zone confusions by relying on the DB for all the date/time formatting and simply copying the generated time stamps. Those values should only be read, but never written programmatically from C++. Otherwise we have to ensure that we are writing the exact same format as SQLite does. |
Is this really the exact column value in PlaylistTracks.pl_datetime_added? I get a different format, i.e. no ISO 8601. |
2020-12-23T09:37:25.373Z is the value from library.datetime_added All different formats :-/ |
library.datetime_added is generated by Mixxx. Using UTC is reasonable for this use case, although using local time + offset would be more appropriate and consistent. PlaylistTracks.pl_datetime_added is generated by SQLite. It is UTC although the time zone is not specified. Moreover using UTC for the history playlists doesn't fit the use case as already discussed, local time + offset would be more appropriate. library.last_played_at is parsed by Qt from SQLite and then stringified by Qt again. Since the SQLite timestamp (in UTC) doesn't mention a time zone Qt assumes local time which is wrong. Nevertheless writing another format than that generated by and copied from PlaylistTracks.pl_datetime_added mixes up the sorting in database queries. |
IMO times should always be stored as UTC and transformed to local time when displayed to the user. This is simple and easy to keep correct. |
completely agree -- DB times should all be UTC and adjusted for current local time. If that means someone gets on a plane and the times look wonky, so be it. |
I think timestamp display issues are out of scope for this PR. This code displays the timestamp in a standard way, and that is good enough here. If we want to adjust the way we display times, let's do that in a followup |
Unfortunately right now the bug is here. The time is read as UTC even though the library stores local time. If you like to fix this this, It can be merged. If we decide to change the time format in the library to UTC which seems to be reasonable, this can be done in this PR or in another PR that needs to be merged before this. In the later case this PR don't need to be changed. If we change the time format we have the issue with alpha users. I think it is the best to deal with them by dropping the current column and create a new one. |
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.
@daschuer Please ignore the column values that are displayed after Mixxx has modified them. Instead re-execute the statement from schema migration 35 and then test if the values are displayed correctly. Anything else is out of scope right now. Why should we delay this PR that only affects the display of those values? |
Using plain UTC for system time stamps and M2M communication is perfect. But it is inappropriate for many user-related use cases and especially contracts. I had to learn this after many years designing data models and interfaces for business services. The current local time zone is arbitrary and should not affect an event that happened in the past and that is associated with a place or geographical location. |
After executing the migration statement the last_played_at column values are displayed correct with this branch.
Because we than don't bother bleeding edge users with a broken feature. I would prefer to have it fixed before.
I agree to that for the history view. This is an issue in the tracks table though, because we would have than Times from different time zones in on column. Do we agree that this should be transformed to local time? |
We could work around that issue by displaying values like "5 minutes ago", "2 days ago", etc. Not sure if that is a good idea. |
This will work for the major use case of finding tracks that have not been been played lets say since a year. For older tracks the wall clock time is not relevant. I am still not clear if there is a use case for finding "dinner" or "late night" tracks. This sound appealing on the first sight, but is probably unreliable so that users better skim through there history itself. We have also crates for this. What do you think? |
Due to lack of knowledge about the time zone or offset we are not able to migrate existing values. I am not investing any time on migrating to a new format. We only have to fix the different formats by storing all values in the SQLite-generated format consistently. Displaying historic data transformed into the current local time zone is confusing. But since everything is stored in UTC we don't have a choice here and need to make a reasonable assumption. If you don't travel between different time zones frequently then the current local time zone is a good guess that should be valid for the majority of users. |
ywwg#10 also splits the database migration to clean up the inconsistent values that have emerged until now. |
QStringBuilder doesn't work for constants!
Fix reading/writing of library.last_played_at
Thank you for joining forces :-) |
No description provided.