mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Compare commits
3 commits
26062a1278
...
7f277612fc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f277612fc | ||
|
|
2f5487cd35 | ||
|
|
5455228b80 |
18 changed files with 35 additions and 83 deletions
|
|
@ -1 +1 @@
|
|||
0.36.5
|
||||
0.37.0
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [0.36.5] - Unreleased
|
||||
# [0.37.0] - 2025-12-30
|
||||
|
||||
## Added
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class BulkVisitsSuggestingJob < ApplicationJob
|
|||
|
||||
users.active.find_each do |user|
|
||||
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)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Tracks::DailyGenerationJob < ApplicationJob
|
|||
|
||||
def perform
|
||||
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)
|
||||
rescue StandardError => e
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class StatsQuery
|
|||
end
|
||||
|
||||
{
|
||||
total: user.points_count,
|
||||
total: user.points_count.to_i,
|
||||
geocoded: cached_stats[:geocoded],
|
||||
without_data: cached_stats[:without_data]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Imports::Destroy
|
|||
end
|
||||
|
||||
def call
|
||||
points_count = @import.points_count
|
||||
points_count = @import.points_count.to_i
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
@import.points.destroy_all
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class PointsLimitExceeded
|
|||
return false if DawarichSettings.self_hosted?
|
||||
|
||||
Rails.cache.fetch(cache_key, expires_in: 1.day) do
|
||||
@user.points_count >= points_limit
|
||||
@user.points_count.to_i >= points_limit
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ class Users::ExportData
|
|||
trips: user.trips.count,
|
||||
stats: user.stats.count,
|
||||
notifications: user.notifications.count,
|
||||
points: user.points_count,
|
||||
points: user.points_count.to_i,
|
||||
visits: user.visits.count,
|
||||
places: user.visited_places.count
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,9 +219,7 @@ class Users::ImportData::Points
|
|||
country_key = [country_info['name'], country_info['iso_a2'], country_info['iso_a3']]
|
||||
country = countries_lookup[country_key]
|
||||
|
||||
if country.nil? && country_info['name'].present?
|
||||
country = countries_lookup[country_info['name']]
|
||||
end
|
||||
country = countries_lookup[country_info['name']] if country.nil? && country_info['name'].present?
|
||||
|
||||
if country
|
||||
attributes['country_id'] = country.id
|
||||
|
|
@ -254,12 +252,12 @@ class Users::ImportData::Points
|
|||
end
|
||||
|
||||
def ensure_lonlat_field(attributes, point_data)
|
||||
if attributes['lonlat'].blank? && point_data['longitude'].present? && point_data['latitude'].present?
|
||||
longitude = point_data['longitude'].to_f
|
||||
latitude = point_data['latitude'].to_f
|
||||
attributes['lonlat'] = "POINT(#{longitude} #{latitude})"
|
||||
logger.debug "Reconstructed lonlat: #{attributes['lonlat']}"
|
||||
end
|
||||
return unless attributes['lonlat'].blank? && point_data['longitude'].present? && point_data['latitude'].present?
|
||||
|
||||
longitude = point_data['longitude'].to_f
|
||||
latitude = point_data['latitude'].to_f
|
||||
attributes['lonlat'] = "POINT(#{longitude} #{latitude})"
|
||||
logger.debug "Reconstructed lonlat: #{attributes['lonlat']}"
|
||||
end
|
||||
|
||||
def normalize_timestamp_for_lookup(timestamp)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<p class="py-6">
|
||||
<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>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<%= number_with_delimiter user.points_count %>
|
||||
<%= number_with_delimiter user.points_count.to_i %>
|
||||
</td>
|
||||
<td>
|
||||
<%= human_datetime(user.created_at) %>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<div class="hero-content text-center py-12">
|
||||
<div class="max-w-lg">
|
||||
<h1 class="text-4xl font-bold"><%= @digest.year %> Year in Review</h1>
|
||||
<p class="py-4">A journey, by the numbers</p>
|
||||
<p class="py-4">Your journey, by the numbers</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@
|
|||
|
||||
<div class="content">
|
||||
<p>
|
||||
Hi, this is Evgenii from Dawarich! Pretty wild journey last yeah, huh? Let's take a look back at all the places you explored in <strong><%= @digest.year %></strong>.
|
||||
Hi, this is Evgenii from Dawarich! Pretty wild journey last year, huh? Let's take a look back at all the places you explored in <strong><%= @digest.year %></strong>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,5 @@ module Dawarich
|
|||
config.active_job.queue_adapter = :sidekiq
|
||||
|
||||
config.action_mailer.preview_paths << Rails.root.join('spec/mailers/previews').to_s
|
||||
|
||||
config.middleware.use Rack::Deflater
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CreatePointsRawDataArchives < ActiveRecord::Migration[8.0]
|
|||
end
|
||||
|
||||
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_foreign_key :points_raw_data_archives, :users, validate: false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,15 +27,19 @@ class AddCompositeIndexToStats < ActiveRecord::Migration[8.0]
|
|||
deleted_count = 0
|
||||
loop do
|
||||
batch_deleted = execute(<<-SQL.squish).cmd_tuples
|
||||
DELETE FROM stats s1
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM stats s2
|
||||
WHERE s2.user_id = s1.user_id
|
||||
AND s2.year = s1.year
|
||||
AND s2.month = s1.month
|
||||
AND s2.id > s1.id
|
||||
DELETE FROM stats
|
||||
WHERE id IN (
|
||||
SELECT s1.id
|
||||
FROM stats s1
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM stats s2
|
||||
WHERE s2.user_id = s1.user_id
|
||||
AND s2.year = s1.year
|
||||
AND s2.month = s1.month
|
||||
AND s2.id > s1.id
|
||||
)
|
||||
LIMIT #{BATCH_SIZE}
|
||||
)
|
||||
LIMIT #{BATCH_SIZE}
|
||||
SQL
|
||||
|
||||
break if batch_deleted.zero?
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddVerifiedAtToPointsRawDataArchives < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :points_raw_data_archives, :verified_at, :datetime
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'devise/shared/_links.html.erb', type: :view do
|
||||
let(:resource_name) { :user }
|
||||
let(:devise_mapping) { Devise.mappings[:user] }
|
||||
|
||||
before do
|
||||
def view.resource_name
|
||||
:user
|
||||
end
|
||||
|
||||
def view.devise_mapping
|
||||
Devise.mappings[:user]
|
||||
end
|
||||
|
||||
def view.resource_class
|
||||
User
|
||||
end
|
||||
|
||||
def view.signed_in?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
context 'with OIDC provider' do
|
||||
before do
|
||||
stub_const('OMNIAUTH_PROVIDERS', [:openid_connect])
|
||||
allow(User).to receive(:omniauth_providers).and_return([:openid_connect])
|
||||
end
|
||||
|
||||
it 'displays custom OIDC provider name' do
|
||||
stub_const('OIDC_PROVIDER_NAME', 'Authentik')
|
||||
|
||||
render
|
||||
|
||||
expect(rendered).to have_button('Sign in with Authentik')
|
||||
end
|
||||
|
||||
it 'displays default name when OIDC_PROVIDER_NAME is not set' do
|
||||
stub_const('OIDC_PROVIDER_NAME', 'Openid Connect')
|
||||
|
||||
render
|
||||
|
||||
expect(rendered).to have_button('Sign in with Openid Connect')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in a new issue