Skip to content

Commit bffed66

Browse files
committed
enh: detect users hitting update_db in short intervals and ask whether to reset DB
1 parent 408677d commit bffed66

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

dcoraid/gui/main.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,27 @@ def check_update_database(self, reset=False, force=False):
167167
)
168168
elif force:
169169
doit = True
170+
if (self.database.local_timestamp > time.time() - 10
171+
and self._last_asked_about_update > time.time() - 1):
172+
# The user might be frantically hitting the update button,
173+
# because something is not showing up. Ask whether to reset
174+
# the database.
175+
button_reply = QtWidgets.QMessageBox.question(
176+
self,
177+
'User frustration detected',
178+
"It seems like you are looking for a dataset that "
179+
"is not here. If something has been modified by someone "
180+
"different than you, it might help to reset the database. "
181+
"Would you like to reset (instead of update) the "
182+
"database? This will delete the local database and fetch "
183+
"all metadata from the DCOR server.",
184+
QtWidgets.QMessageBox.StandardButton.Yes
185+
| QtWidgets.QMessageBox.StandardButton.No,
186+
QtWidgets.QMessageBox.StandardButton.No)
187+
reset_db = (button_reply
188+
== QtWidgets.QMessageBox.StandardButton.Yes)
189+
if reset_db:
190+
self.database.reset_cache()
170191
else:
171192
if (self.database.local_timestamp < time.time() - 24*3600
172193
and self._last_asked_about_update < time.time() - 3600):

0 commit comments

Comments
 (0)