Skip to content
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

Fix empty database missing 'modified' time causing table to not show #1182

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

marc-vdm
Copy link
Member

changes:

  • Creating a new database now adds modified time by writing nothing (empty dict) to the new database.
  • In case modified is still missing (e.g. user created empty database in Brightway), we just write current time to the modified column in AB.
  • Also removed some tz shifting code that's unused since Table columns with dates are now sorted based on the date #1151.

Checklist

  • Keep pull requests small so they can be easily reviewed.
  • Update the documentation, please follow the numpy style guide.
  • Update tests.
  • Categorize the PR by setting a good title and adding one of the labels:
    bug, feature, ui, change, documentation, breaking, ci
    as they show up in the changelog.
  • Link this PR to related issues by using closing keywords.
  • Request a review from another developer.

@marc-vdm marc-vdm added the bug Issues/PRs related to bugs label Dec 27, 2023
@marc-vdm marc-vdm added this to the 2.9.4 milestone Dec 27, 2023
@marc-vdm marc-vdm requested a review from mrvisscher December 27, 2023 10:48
@coveralls
Copy link

coveralls commented Dec 27, 2023

Coverage Status

coverage: 50.565% (-0.004%) from 50.569%
when pulling cc0e162 on marc-vdm:date_sort_bug
into 6ece1b3 on LCA-ActivityBrowser:master.

Copy link
Collaborator

@mrvisscher mrvisscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know whether you have the time to make this work Marc, otherwise I'll take a look at it further down the line.

@@ -54,6 +54,7 @@ def data(self, index, role=Qt.DisplayRole):

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method has become very unclear over the last commits. Maybe we should chop it up into different functions/methods. e.g. a value function that returns the value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A switch case block also comes to mind. Those are awfully quick, meant for enums like these, and easy to read. Just spitballing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the whole date thing could go in a child class for the DB table as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method has become very unclear over the last commits. Maybe we should chop it up into different functions/methods. e.g. a value function that returns the value.

Agree, it's a bit messy atm

A switch case block also comes to mind. Those are awfully quick, meant for enums like these, and easy to read. Just spitballing

switch only exists from py=3.10, so we can't implement this until we drop support for 3.9. Though elif is essentially a switch, and I don't think the speed matters in this case.

Maybe the whole date thing could go in a child class for the DB table as well

Also agree

Comment on lines +82 to +83
if tt_date_flag and role == Qt.ToolTipRole:
return value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just return the value where you've set the flag? That would clear the code up nicely

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case you wouldn't need the flag to begin with.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just return the value where you've set the flag? That would clear the code up nicely

That's what I had earlier, but thought this may be more consistent as there's no returns in other places

@marc-vdm
Copy link
Member Author

marc-vdm commented Jan 8, 2024

Ok, so I agree this is not great right now, however, I do think we should have something to resolve the issue in the next release, as this is very confusing for users if they suddenly can't see their databases due to something that seems entirely unrelated.

What about we open an issue for a proper re-write but merge this? Or otherwise if you have time for a re-write before the next release that should also work.

@marc-vdm
Copy link
Member Author

marc-vdm commented Jan 8, 2024

Oh or we could revert to this state and just make an issue for the time formatted tooltip, that's where the mess is right now.

@mrvisscher
Copy link
Collaborator

Ok, so I agree this is not great right now, however, I do think we should have something to resolve the issue in the next release, as this is very confusing for users if they suddenly can't see their databases due to something that seems entirely unrelated.

What about we open an issue for a proper re-write but merge this? Or otherwise if you have time for a re-write before the next release that should also work.

Good points. Let's rewrite it properly in another release, I'll merge this and create an issue.

@mrvisscher mrvisscher merged commit 3c58cff into LCA-ActivityBrowser:master Jan 9, 2024
12 checks passed
Copy link

github-actions bot commented Jan 9, 2024

Note

This issue has been implemented in the new release of Activity Browser 🚀 (version 2.9.4), you can get the new version by updating Activity Browser.

Do you want to be notified of new releases of Activity Browser? Subscribe to our updates mailing list ✉.

🤖_beep boop! I'm a bot and this message was an automated action._
If updating does not make sense for this issue, just ignore this.

@marc-vdm marc-vdm deleted the date_sort_bug branch May 14, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues/PRs related to bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timezone sorting and empty databases
3 participants