Skip to content

Commit 8217155

Browse files
committed
fix: reduce user circle list cache lifetime to 10 s
1 parent 2151007 commit 8217155

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- feat: add circle archiving wizard GUI
44
- fix: handle resource downloads whose target directory got deleted
55
- fix: check for existence of persistent job list in upload
6+
- fix: reduce user circle list cache lifetime to 10 s
67
- enh: allow to programmatically abort download jobs
78
- ref: move setup wizard to `wizard_init` submodule
89
1.0.0

dcoraid/api/ckan_api.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,23 @@ def __init__(self,
8686
kwargs = {"backend": "sqlite",
8787
"cache_name": pathlib.Path(caching)}
8888
self.req_ses = requests_cache.CachedSession(urls_expire_after={
89-
# API calls without parameters; seconds cached
90-
self.api_url + "user_show": 5,
91-
self.api_url + "user_autocomplete": 30,
92-
self.api_url + "group_list": 10,
93-
self.api_url + "user_list": 30,
94-
self.api_url + "status_show": 60,
95-
self.api_url + "organization_list": 60,
89+
# The first item that matches is used, so we have to specify
90+
# longer URLs with shorted lifetime first.
9691
# API calls with parameters
9792
self.api_url + "package_search*": 10,
9893
self.api_url + "package_collaborator_list_for_user*": 60,
99-
self.api_url + "organization_list_for_user*": 60,
94+
self.api_url + "organization_list_for_user*": 10,
10095
self.api_url + "group_list_authz*": 60,
10196
self.api_url + "dataset_followee_list*": 3600,
10297
self.api_url + "package_show*": requests_cache.DO_NOT_CACHE,
10398
self.api_url + "resource_show*": requests_cache.DO_NOT_CACHE,
99+
# API calls without parameters; seconds cached
100+
self.api_url + "user_show": 5,
101+
self.api_url + "user_autocomplete": 30,
102+
self.api_url + "group_list": 10,
103+
self.api_url + "user_list": 30,
104+
self.api_url + "status_show": 60,
105+
self.api_url + "organization_list": 60,
104106
"*": requests_cache.DO_NOT_CACHE,
105107
},
106108
**kwargs)

dcoraid/gui/panel_uploads/circle_mgr.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def get_user_circle_dicts():
1010
"""Conveniently cache the organization list for the user
1111
12-
You must call `self._get_user_circle_dicts.cache_clear`
12+
You must call `get_user_circle_dicts.cache_clear`
1313
if the circle list changes (e.g. because you added one).
1414
"""
1515
api = get_ckan_api()
@@ -34,18 +34,17 @@ def ask_for_new_circle(parent_widget):
3434
text, ok_pressed = QtWidgets.QInputDialog.getText(
3535
parent_widget,
3636
"Circle required",
37-
"You do not have access to any existing Circles. To upload\n"
38-
+ "datasets, you need to be either Editor or Admin in\n"
39-
+ "a Circle. You may create a Circle now or cancel and ask\n"
40-
+ "a colleague to add you to a Circle (Your user name is "
41-
+ "'{}').".format(ud["name"])
42-
+ "\n\nTo proceed with Circle creation, please choose a name:",
37+
f"You do not have access to any existing Circles. To upload\n"
38+
f"datasets, you need to be either Editor or Admin in\n"
39+
f"a Circle. You may create a Circle now or cancel and ask\n"
40+
f"a colleague to add you to a Circle (Your user name is "
41+
f"'{ud['name']}')."
42+
f"\n\nTo proceed with Circle creation, please choose a name:",
4343
QtWidgets.QLineEdit.EchoMode.Normal,
4444
f"{name}'s Circle")
4545
if ok_pressed and text != '':
46-
cname = "user-circle-{}".format(ud["name"])
4746
cdict = api.post("organization_create",
48-
data={"name": cname,
47+
data={"name": f"user-circle-{ud['name']}",
4948
"title": text.strip(),
5049
})
5150
# invalidate cache, because now we have a new circle

0 commit comments

Comments
 (0)