Bring points_count to integer

This commit is contained in:
Eugene Burmakin 2025-12-28 20:55:57 +01:00
parent 26062a1278
commit 5455228b80
9 changed files with 10 additions and 10 deletions

View file

@ -18,7 +18,7 @@ class BulkVisitsSuggestingJob < ApplicationJob
users.active.find_each do |user| users.active.find_each do |user|
next unless user.safe_settings.visits_suggestions_enabled? next unless user.safe_settings.visits_suggestions_enabled?
next unless user.points_count.positive? next unless user.points_count&.positive?
schedule_chunked_jobs(user, time_chunks) schedule_chunked_jobs(user, time_chunks)
end end

View file

@ -21,7 +21,7 @@ class Tracks::DailyGenerationJob < ApplicationJob
def perform def perform
User.active_or_trial.find_each do |user| User.active_or_trial.find_each do |user|
next if user.points_count.zero? next if user.points_count&.zero?
process_user_daily_tracks(user) process_user_daily_tracks(user)
rescue StandardError => e rescue StandardError => e

View file

@ -11,7 +11,7 @@ class StatsQuery
end end
{ {
total: user.points_count, total: user.points_count.to_i,
geocoded: cached_stats[:geocoded], geocoded: cached_stats[:geocoded],
without_data: cached_stats[:without_data] without_data: cached_stats[:without_data]
} }

View file

@ -9,7 +9,7 @@ class Imports::Destroy
end end
def call def call
points_count = @import.points_count points_count = @import.points_count.to_i
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@import.points.destroy_all @import.points.destroy_all

View file

@ -9,7 +9,7 @@ class PointsLimitExceeded
return false if DawarichSettings.self_hosted? return false if DawarichSettings.self_hosted?
Rails.cache.fetch(cache_key, expires_in: 1.day) do Rails.cache.fetch(cache_key, expires_in: 1.day) do
@user.points_count >= points_limit @user.points_count.to_i >= points_limit
end end
end end

View file

@ -323,7 +323,7 @@ class Users::ExportData
trips: user.trips.count, trips: user.trips.count,
stats: user.stats.count, stats: user.stats.count,
notifications: user.notifications.count, notifications: user.notifications.count,
points: user.points_count, points: user.points_count.to_i,
visits: user.visits.count, visits: user.visits.count,
places: user.visited_places.count places: user.visited_places.count
} }

View file

@ -1,6 +1,6 @@
<p class="py-6"> <p class="py-6">
<p class='py-2'> <p class='py-2'>
You have used <%= number_with_delimiter(current_user.points_count) %> points of <%= number_with_delimiter(DawarichSettings::BASIC_PAID_PLAN_LIMIT) %> available. You have used <%= number_with_delimiter(current_user.points_count.to_i) %> points of <%= number_with_delimiter(DawarichSettings::BASIC_PAID_PLAN_LIMIT) %> available.
</p> </p>
<progress class="progress progress-primary w-1/2 h-5" value="<%= current_user.points_count %>" max="<%= DawarichSettings::BASIC_PAID_PLAN_LIMIT %>"></progress> <progress class="progress progress-primary w-1/2 h-5" value="<%= current_user.points_count.to_i %>" max="<%= DawarichSettings::BASIC_PAID_PLAN_LIMIT %>"></progress>
</p> </p>

View file

@ -24,7 +24,7 @@
</div> </div>
</td> </td>
<td> <td>
<%= number_with_delimiter user.points_count %> <%= number_with_delimiter user.points_count.to_i %>
</td> </td>
<td> <td>
<%= human_datetime(user.created_at) %> <%= human_datetime(user.created_at) %>

View file

@ -16,7 +16,7 @@ class CreatePointsRawDataArchives < ActiveRecord::Migration[8.0]
end end
add_index :points_raw_data_archives, :user_id add_index :points_raw_data_archives, :user_id
add_index :points_raw_data_archives, [:user_id, :year, :month] add_index :points_raw_data_archives, %i[user_id year month]
add_index :points_raw_data_archives, :archived_at add_index :points_raw_data_archives, :archived_at
add_foreign_key :points_raw_data_archives, :users, validate: false add_foreign_key :points_raw_data_archives, :users, validate: false
end end