mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Minor changes
This commit is contained in:
parent
c25bb6f4d4
commit
c12709ac15
4 changed files with 7 additions and 14 deletions
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
module Users
|
||||
module DigestsHelper
|
||||
EARTH_CIRCUMFERENCE_KM = 40_075
|
||||
MOON_DISTANCE_KM = 384_400
|
||||
|
||||
def distance_with_unit(distance_meters, unit)
|
||||
value = Users::Digest.convert_distance(distance_meters, unit).round
|
||||
"#{number_with_delimiter(value)} #{unit}"
|
||||
|
|
@ -13,11 +10,11 @@ module Users
|
|||
def distance_comparison_text(distance_meters)
|
||||
distance_km = distance_meters.to_f / 1000
|
||||
|
||||
if distance_km >= MOON_DISTANCE_KM
|
||||
percentage = ((distance_km / MOON_DISTANCE_KM) * 100).round(1)
|
||||
if distance_km >= Users::Digest::MOON_DISTANCE_KM
|
||||
percentage = ((distance_km / Users::Digest::MOON_DISTANCE_KM) * 100).round(1)
|
||||
"That's #{percentage}% of the distance to the Moon!"
|
||||
else
|
||||
percentage = ((distance_km / EARTH_CIRCUMFERENCE_KM) * 100).round(1)
|
||||
percentage = ((distance_km / Users::Digest::EARTH_CIRCUMFERENCE_KM) * 100).round(1)
|
||||
"That's #{percentage}% of Earth's circumference!"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ class Users::Digests::CalculatingJob < ApplicationJob
|
|||
content: "#{error.message}, stacktrace: #{error.backtrace.join("\n")}"
|
||||
).call
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# User was deleted, nothing to notify
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class Users::Digests::EmailSendingJob < ApplicationJob
|
|||
|
||||
def should_send_email?(user, digest)
|
||||
return false unless user.safe_settings.digest_emails_enabled?
|
||||
return false unless digest.present?
|
||||
return false if digest.sent_at.present? # Already sent
|
||||
return false if digest.blank?
|
||||
return false if digest.sent_at.present?
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,15 +10,13 @@ class Users::Digest < ApplicationRecord
|
|||
|
||||
belongs_to :user
|
||||
|
||||
validates :year, presence: true
|
||||
validates :period_type, presence: true
|
||||
validates :year, :period_type, presence: true
|
||||
validates :year, uniqueness: { scope: %i[user_id period_type] }
|
||||
|
||||
before_create :generate_sharing_uuid
|
||||
|
||||
enum :period_type, { monthly: 0, yearly: 1 }
|
||||
|
||||
# Sharing methods (following Stat model pattern)
|
||||
def sharing_enabled?
|
||||
sharing_settings.try(:[], 'enabled') == true
|
||||
end
|
||||
|
|
@ -76,8 +74,6 @@ class Users::Digest < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
# Helper methods for accessing digest data
|
||||
# toponyms is an array like: [{'country' => 'Germany', 'cities' => [{'city' => 'Berlin'}]}]
|
||||
def countries_count
|
||||
return 0 unless toponyms.is_a?(Array)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue