2025-02-10 14:37:20 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Settings::MapsController < ApplicationController
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@maps = current_user.safe_settings.maps
|
2025-02-13 15:04:29 -05:00
|
|
|
|
|
|
|
|
@tile_usage = 7.days.ago.to_date.upto(Time.zone.today).map do |date|
|
|
|
|
|
[
|
|
|
|
|
date.to_s,
|
|
|
|
|
Rails.cache.read("dawarich_map_tiles_usage:#{current_user.id}:#{date}") || 0
|
|
|
|
|
]
|
|
|
|
|
end
|
2025-02-10 14:37:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
current_user.settings['maps'] = settings_params
|
|
|
|
|
current_user.save!
|
|
|
|
|
|
|
|
|
|
redirect_to settings_maps_path, notice: 'Settings updated'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def settings_params
|
2025-12-06 14:54:49 -05:00
|
|
|
params.require(:maps).permit(:name, :url, :distance_unit, :preferred_version)
|
2025-02-10 14:37:20 -05:00
|
|
|
end
|
|
|
|
|
end
|