mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
29 lines
636 B
Ruby
29 lines
636 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Settings::MapsController < ApplicationController
|
|
before_action :authenticate_user!
|
|
|
|
def index
|
|
@maps = current_user.safe_settings.maps
|
|
|
|
@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
|
|
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
|
|
params.require(:maps).permit(:name, :url)
|
|
end
|
|
end
|