-
Notifications
You must be signed in to change notification settings - Fork 642
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
[snapshots] record snapshot creation time #3125
Conversation
Codecov Report
@@ Coverage Diff @@
## snapshots #3125 +/- ##
=============================================
- Coverage 84.21% 84.13% -0.08%
=============================================
Files 246 246
Lines 13152 13164 +12
=============================================
Hits 11076 11076
- Misses 2076 2088 +12
|
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.
Good stuff @sharder996, thanks!
: BaseSnapshot{json["name"].toString().toStdString(), // name | ||
json["comment"].toString().toStdString(), // comment | ||
QDateTime::fromString(json["creation_timestamp"].toString(), | ||
"yyyy-MM-ddTHH:mm:ss.zzzZ"), // creation_timestamp |
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.
Isn't this pretty much the same as Qt::ISODate
? In any case, can you extract a constant please?
ad8652b
to
cf24856
Compare
cf24856
to
d4809df
Compare
d4809df
to
cf24856
Compare
cf24856
to
d234eb1
Compare
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.
Almost.
|
||
private: | ||
std::string name; | ||
std::string comment; | ||
const QDateTime creation_timestamp; |
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.
All other const fields are below, after a comment explaining them. Is there a reason why you need this order? Otherwise, could you move the timestamp there?
e65404d
to
d5037b4
Compare
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.
Hey @sharder996, one final detail that I missed before. And this needs a rebase now.
@@ -134,6 +145,7 @@ QJsonObject multipass::BaseSnapshot::serialize() const | |||
|
|||
snapshot.insert("name", QString::fromStdString(name)); | |||
snapshot.insert("comment", QString::fromStdString(comment)); | |||
snapshot.insert("creation_timestamp", creation_timestamp.toString(Qt::ISODate)); |
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.
I just realized this was dropping milliseconds. There is a Qt::ISODateWithMs
which is closer (same?) to what you had initially.
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.
BTW, I believe this explains the wrong order after loading snapshots that were taken in quick succession:
$ mp snapshot b -n foo && mp snapshot a -n bar && mp snapshot b -n bar && mp snapshot b -n baz && mp snapshot a -n baz && mp snapshot a -n foo
Snapshot taken: b.foo
Snapshot taken: a.bar
Snapshot taken: b.bar
Snapshot taken: b.baz
Snapshot taken: a.baz
Snapshot taken: a.foo
$ multipass info --snapshot-overview --all Instance Snapshot Parent Comment
a bar -- --
a baz bar --
a foo baz --
b foo -- --
b bar foo --
b baz bar --
$ snap stop multipass.multipassd
2023-06-28T12:43:29+01:00 INFO Waiting for "snap.multipass.multipassd.service" to stop.
Stopped.
$ snap start multipass.multipassd
Started.
$ multipass info --snapshot-overview --all
Instance Snapshot Parent Comment
a bar -- --
a foo baz --
a baz bar --
b foo -- --
b baz bar --
b bar foo --
d5037b4
to
976eb07
Compare
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.
Yup, that's it!
[snapshots] record snapshot creation time
[snapshots] record snapshot creation time
[snapshots] record snapshot creation time
Debated the use of
QDateTime
vsstd::chrono::time_point
, but some functions that would be useful for serializing the object to a string and vice versa are only available in C++20. You can still make it work with the C++17 STL, but you will be forced to usestd::time_t
in places. Depending on the platform,std::time_t
can be only 32 bits, meaning that its maximmum date is sometime in 2038.