Add a setting for maximum age of events

This commit is contained in:
Dan Milne
2025-11-17 16:17:59 +11:00
parent 830810305b
commit 5d3e35a4ac
5 changed files with 42 additions and 17 deletions

View File

@@ -50,11 +50,37 @@
</div>
</div>
<!-- Future Settings Section -->
<div class="mt-6 bg-gray-50 shadow sm:rounded-lg">
<!-- Data Retention Settings -->
<div class="mt-6 bg-white shadow sm:rounded-lg">
<div class="px-4 py-5 sm:p-6">
<h3 class="text-lg font-medium leading-6 text-gray-900 mb-2">Additional Settings</h3>
<p class="text-sm text-gray-500">More configuration options will be added here as needed.</p>
<h3 class="text-lg font-medium leading-6 text-gray-900 mb-4">Data Retention</h3>
<div class="mb-6">
<%= form_with url: settings_path, method: :patch, class: "space-y-4" do |f| %>
<%= hidden_field_tag :key, 'event_retention_days' %>
<div>
<label for="event_retention_days" class="block text-sm font-medium text-gray-700">
Event Retention Period (days)
</label>
<div class="mt-1 flex rounded-md shadow-sm">
<%= number_field_tag :value,
@settings['event_retention_days']&.value || 90,
class: "flex-1 min-w-0 block w-full px-3 py-2 rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 sm:text-sm",
placeholder: "90",
min: 0 %>
<%= f.submit "Update", class: "ml-3 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" %>
</div>
<p class="mt-2 text-sm text-gray-500">
Events older than this many days will be automatically deleted by the cleanup job (runs hourly).
Set to 0 to disable automatic cleanup. Default: 90 days.
</p>
<p class="mt-1 text-xs text-gray-400">
Current setting: <strong><%= Setting.event_retention_days %> days</strong>
</p>
</div>
<% end %>
</div>
</div>
</div>
</div>