File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1+ from pyramid .settings import aslist
2+
13from kinto .authorization import PERMISSIONS_INHERITANCE_TREE
24from kinto .core import metrics
35from kinto .core .events import ResourceChanged
68
79
810def includeme (config ):
11+ settings = config .get_settings ()
12+ exposed_settings = {}
13+ if (trim_history_max := int (settings .get ("history.auto_trim_max_count" , "-1" ))) > 0 :
14+ exposed_settings ["auto_trim_max_count" ] = trim_history_max
15+ if trim_user_ids := aslist (settings .get ("history.auto_trim_user_ids" , "" )):
16+ exposed_settings ["auto_trim_user_ids" ] = trim_user_ids
17+
918 config .add_api_capability (
1019 "history" ,
1120 description = "Track changes on data." ,
1221 url = "http://kinto.readthedocs.io/en/latest/api/1.x/history.html" ,
22+ ** exposed_settings ,
1323 )
1424
1525 # Activate end-points.
Original file line number Diff line number Diff line change @@ -162,7 +162,15 @@ def on_resource_changed(event):
162162 filters = filters
163163 + [Filter ("last_modified" , trim_before_timestamp , COMPARISON .MAX )],
164164 )
165- logger .debug (f"Trimmed { len (deleted )} old history entries." )
165+ logger .info (f"Trimmed { len (deleted )} old history entries." )
166+ else :
167+ logger .info (
168+ "No old history to trim for {user_id!r} on {resource_name!r} in {bucket_uri!r}."
169+ )
170+ else :
171+ logger .info (
172+ f"Trimming of old history entries is not enabled{ f' for { user_id !r} .' if is_trim_enabled else '.' } "
173+ )
166174
167175 # Without explicit permissions, the ACLs on the history entries will
168176 # fully depend on the inherited permission tree (eg. bucket:read, bucket:write).
You can’t perform that action at this time.
0 commit comments