mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-13 02:31:39 -05:00
Merge remote-tracking branch 'origin/dev' into feature/subscription
This commit is contained in:
commit
600c88ae01
27 changed files with 309 additions and 254 deletions
|
|
@ -71,3 +71,4 @@ volumes:
|
|||
dawarich_shared:
|
||||
dawarich_public:
|
||||
dawarich_watched:
|
||||
dawarich_storage:
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ If your hardware doesn't have enough memory to migrate the imports, you can dele
|
|||
- `rake points:migrate_to_lonlat` task now also reindexes the points table.
|
||||
- Fixed filling `lonlat` column for old places after reverse geocoding.
|
||||
- Deleting an import now correctly recalculates stats.
|
||||
- Datetime across the app is now being displayed in human readable format, i.e 26 Dec 2024, 13:49. Hover over the datetime to see the ISO 8601 timestamp.
|
||||
|
||||
|
||||
# 0.25.3 - 2025-03-22
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ApiController < ApplicationController
|
|||
end
|
||||
|
||||
def authenticate_active_api_user!
|
||||
render json: { error: 'User is not active' }, status: :unauthorized unless current_api_user&.active?
|
||||
render json: { error: 'User is not active' }, status: :unauthorized unless current_api_user&.active_until&.future?
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def authenticate_active_user!
|
||||
return if current_user&.active?
|
||||
return if current_user&.active_until&.future?
|
||||
|
||||
redirect_to root_path, notice: 'Your account is not active.', status: :see_other
|
||||
end
|
||||
|
|
|
|||
|
|
@ -115,6 +115,17 @@ module ApplicationHelper
|
|||
date.strftime('%e %B %Y')
|
||||
end
|
||||
|
||||
def human_datetime(datetime)
|
||||
return unless datetime
|
||||
|
||||
content_tag(
|
||||
:span,
|
||||
datetime.strftime('%e %b %Y, %H:%M'),
|
||||
class: 'tooltip',
|
||||
data: { tip: datetime.iso8601 }
|
||||
)
|
||||
end
|
||||
|
||||
def speed_text_color(speed)
|
||||
return 'text-default' if speed.to_i >= 0
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,8 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def activate
|
||||
update(status: :active)
|
||||
# TODO: Remove the `status` column in the future.
|
||||
update(status: :active, active_until: 1000.years.from_now)
|
||||
end
|
||||
|
||||
def sanitize_input
|
||||
|
|
@ -150,6 +151,6 @@ class User < ApplicationRecord
|
|||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def can_subscribe?
|
||||
!active? && !DawarichSettings.self_hosted?
|
||||
active_until&.past? && !DawarichSettings.self_hosted?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<% @exports.each do |export| %>
|
||||
<tr>
|
||||
<td><%= export.name %></td>
|
||||
<td><%= export.created_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
|
||||
<td><%= human_datetime(export.created_at) %></td>
|
||||
<td><%= export.status %></td>
|
||||
<td>
|
||||
<% if export.completed? %>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<td>
|
||||
<%= "#{number_with_delimiter import.points.size}" %>
|
||||
</td>
|
||||
<td><%= import.created_at.strftime("%d.%m.%Y, %H:%M") %></td>
|
||||
<td><%= human_datetime(import.created_at) %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -68,12 +68,17 @@
|
|||
<td data-reverse-geocoded-points-count>
|
||||
<%= number_with_delimiter import.reverse_geocoded_points_count %>
|
||||
</td>
|
||||
<td><%= import.created_at.strftime("%d.%m.%Y, %H:%M") %></td>
|
||||
<td><%= human_datetime(import.created_at) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="flex justify-center my-5">
|
||||
<div class='flex'>
|
||||
<%= paginate @imports %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
<% @places.each do |place| %>
|
||||
<tr>
|
||||
<td><%= place.name %></td>
|
||||
<td><%= place.created_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
|
||||
<td><%= human_datetime(place.created_at) %></td>
|
||||
<td><%= "#{place.lat}, #{place.lon}" %></td>
|
||||
<td>
|
||||
<%= link_to 'Delete', place, data: { confirm: "Are you sure? Deleting a place will result in deleting all visits for this place.", turbo_confirm: "Are you sure? Deleting a place will result in deleting all visits for this place.", turbo_method: :delete }, method: :delete, class: "px-4 py-2 bg-red-500 text-white rounded-md" %>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
%>
|
||||
</td>
|
||||
<td class='<%= speed_text_color(point.velocity) %>'><%= point.velocity %></td>
|
||||
<td><%= point.recorded_at %></td>
|
||||
<td><%= human_datetime(point.recorded_at) %></td>
|
||||
<td><%= point.lat %>, <%= point.lon %></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
<%= number_with_delimiter user.tracked_points.count %>
|
||||
</td>
|
||||
<td>
|
||||
<%= user.created_at.strftime('%Y-%m-%d %H:%M:%S') %>
|
||||
<%= human_datetime(user.created_at) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "../config/application"
|
||||
require "importmap/commands"
|
||||
require_relative '../config/application'
|
||||
require 'importmap/commands'
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ pin_all_from 'app/javascript/channels', under: 'channels'
|
|||
|
||||
pin 'application', preload: true
|
||||
pin '@rails/actioncable', to: 'actioncable.esm.js'
|
||||
pin '@rails/activestorage', to: 'activestorage.esm.js'
|
||||
pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true
|
||||
pin '@hotwired/stimulus', to: 'stimulus.min.js', preload: true
|
||||
pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js', preload: true
|
||||
|
|
@ -17,10 +18,8 @@ pin 'chartkick', to: 'chartkick.js'
|
|||
pin 'Chart.bundle', to: 'Chart.bundle.js'
|
||||
pin 'leaflet.heat' # @0.2.0
|
||||
pin 'leaflet-draw' # @1.0.4
|
||||
pin '@rails/actioncable', to: 'actioncable.esm.js'
|
||||
pin_all_from 'app/javascript/channels', under: 'channels'
|
||||
pin 'notifications_channel', to: 'channels/notifications_channel.js'
|
||||
pin 'points_channel', to: 'channels/points_channel.js'
|
||||
pin 'imports_channel', to: 'channels/imports_channel.js'
|
||||
pin "trix"
|
||||
pin "@rails/actiontext", to: "actiontext.esm.js"
|
||||
pin 'trix'
|
||||
pin '@rails/actiontext', to: 'actiontext.esm.js'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SetActiveUntilForSelfhostedUsers < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
return unless DawarichSettings.self_hosted?
|
||||
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
User.where(active_until: nil).update_all(active_until: 1000.years.from_now)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
|
||||
def down
|
||||
return unless DawarichSettings.self_hosted?
|
||||
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
User.where.not(active_until: nil).update_all(active_until: nil)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
end
|
||||
|
|
@ -1 +1 @@
|
|||
DataMigrate::Data.define(version: 20250403204658)
|
||||
DataMigrate::Data.define(version: 20_250_404_182_629)
|
||||
|
|
|
|||
7
db/migrate/20250404182437_add_active_until_to_users.rb
Normal file
7
db/migrate/20250404182437_add_active_until_to_users.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddActiveUntilToUsers < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :users, :active_until, :datetime
|
||||
end
|
||||
end
|
||||
446
db/schema.rb
generated
446
db/schema.rb
generated
|
|
@ -10,260 +10,264 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_03_24_180755) do
|
||||
ActiveRecord::Schema[8.0].define(version: 20_250_404_182_437) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
enable_extension "postgis"
|
||||
enable_extension 'pg_catalog.plpgsql'
|
||||
enable_extension 'postgis'
|
||||
|
||||
create_table "action_text_rich_texts", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.text "body"
|
||||
t.string "record_type", null: false
|
||||
t.bigint "record_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
|
||||
create_table 'action_text_rich_texts', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.text 'body'
|
||||
t.string 'record_type', null: false
|
||||
t.bigint 'record_id', null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.index %w[record_type record_id name], name: 'index_action_text_rich_texts_uniqueness', unique: true
|
||||
end
|
||||
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
t.bigint "record_id", null: false
|
||||
t.bigint "blob_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
||||
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
||||
create_table 'active_storage_attachments', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.string 'record_type', null: false
|
||||
t.bigint 'record_id', null: false
|
||||
t.bigint 'blob_id', null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.index ['blob_id'], name: 'index_active_storage_attachments_on_blob_id'
|
||||
t.index %w[record_type record_id name blob_id], name: 'index_active_storage_attachments_uniqueness',
|
||||
unique: true
|
||||
end
|
||||
|
||||
create_table "active_storage_blobs", force: :cascade do |t|
|
||||
t.string "key", null: false
|
||||
t.string "filename", null: false
|
||||
t.string "content_type"
|
||||
t.text "metadata"
|
||||
t.string "service_name", null: false
|
||||
t.bigint "byte_size", null: false
|
||||
t.string "checksum"
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
|
||||
create_table 'active_storage_blobs', force: :cascade do |t|
|
||||
t.string 'key', null: false
|
||||
t.string 'filename', null: false
|
||||
t.string 'content_type'
|
||||
t.text 'metadata'
|
||||
t.string 'service_name', null: false
|
||||
t.bigint 'byte_size', null: false
|
||||
t.string 'checksum'
|
||||
t.datetime 'created_at', null: false
|
||||
t.index ['key'], name: 'index_active_storage_blobs_on_key', unique: true
|
||||
end
|
||||
|
||||
create_table "active_storage_variant_records", force: :cascade do |t|
|
||||
t.bigint "blob_id", null: false
|
||||
t.string "variation_digest", null: false
|
||||
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
|
||||
create_table 'active_storage_variant_records', force: :cascade do |t|
|
||||
t.bigint 'blob_id', null: false
|
||||
t.string 'variation_digest', null: false
|
||||
t.index %w[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true
|
||||
end
|
||||
|
||||
create_table "areas", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.decimal "longitude", precision: 10, scale: 6, null: false
|
||||
t.decimal "latitude", precision: 10, scale: 6, null: false
|
||||
t.integer "radius", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["user_id"], name: "index_areas_on_user_id"
|
||||
create_table 'areas', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.bigint 'user_id', null: false
|
||||
t.decimal 'longitude', precision: 10, scale: 6, null: false
|
||||
t.decimal 'latitude', precision: 10, scale: 6, null: false
|
||||
t.integer 'radius', null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.index ['user_id'], name: 'index_areas_on_user_id'
|
||||
end
|
||||
|
||||
create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t|
|
||||
create_table 'data_migrations', primary_key: 'version', id: :string, force: :cascade do |t|
|
||||
end
|
||||
|
||||
create_table "exports", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "url"
|
||||
t.integer "status", default: 0, null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "file_format", default: 0
|
||||
t.datetime "start_at"
|
||||
t.datetime "end_at"
|
||||
t.index ["status"], name: "index_exports_on_status"
|
||||
t.index ["user_id"], name: "index_exports_on_user_id"
|
||||
create_table 'exports', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.string 'url'
|
||||
t.integer 'status', default: 0, null: false
|
||||
t.bigint 'user_id', null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.integer 'file_format', default: 0
|
||||
t.datetime 'start_at'
|
||||
t.datetime 'end_at'
|
||||
t.index ['status'], name: 'index_exports_on_status'
|
||||
t.index ['user_id'], name: 'index_exports_on_user_id'
|
||||
end
|
||||
|
||||
create_table "imports", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.integer "source", default: 0
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "raw_points", default: 0
|
||||
t.integer "doubles", default: 0
|
||||
t.integer "processed", default: 0
|
||||
t.jsonb "raw_data"
|
||||
t.integer "points_count", default: 0
|
||||
t.index ["source"], name: "index_imports_on_source"
|
||||
t.index ["user_id"], name: "index_imports_on_user_id"
|
||||
create_table 'imports', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.bigint 'user_id', null: false
|
||||
t.integer 'source', default: 0
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.integer 'raw_points', default: 0
|
||||
t.integer 'doubles', default: 0
|
||||
t.integer 'processed', default: 0
|
||||
t.jsonb 'raw_data'
|
||||
t.integer 'points_count', default: 0
|
||||
t.index ['source'], name: 'index_imports_on_source'
|
||||
t.index ['user_id'], name: 'index_imports_on_user_id'
|
||||
end
|
||||
|
||||
create_table "notifications", force: :cascade do |t|
|
||||
t.string "title", null: false
|
||||
t.text "content", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.integer "kind", default: 0, null: false
|
||||
t.datetime "read_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["kind"], name: "index_notifications_on_kind"
|
||||
t.index ["user_id"], name: "index_notifications_on_user_id"
|
||||
create_table 'notifications', force: :cascade do |t|
|
||||
t.string 'title', null: false
|
||||
t.text 'content', null: false
|
||||
t.bigint 'user_id', null: false
|
||||
t.integer 'kind', default: 0, null: false
|
||||
t.datetime 'read_at'
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.index ['kind'], name: 'index_notifications_on_kind'
|
||||
t.index ['user_id'], name: 'index_notifications_on_user_id'
|
||||
end
|
||||
|
||||
create_table "place_visits", force: :cascade do |t|
|
||||
t.bigint "place_id", null: false
|
||||
t.bigint "visit_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["place_id"], name: "index_place_visits_on_place_id"
|
||||
t.index ["visit_id"], name: "index_place_visits_on_visit_id"
|
||||
create_table 'place_visits', force: :cascade do |t|
|
||||
t.bigint 'place_id', null: false
|
||||
t.bigint 'visit_id', null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.index ['place_id'], name: 'index_place_visits_on_place_id'
|
||||
t.index ['visit_id'], name: 'index_place_visits_on_visit_id'
|
||||
end
|
||||
|
||||
create_table "places", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.decimal "longitude", precision: 10, scale: 6, null: false
|
||||
t.decimal "latitude", precision: 10, scale: 6, null: false
|
||||
t.string "city"
|
||||
t.string "country"
|
||||
t.integer "source", default: 0
|
||||
t.jsonb "geodata", default: {}, null: false
|
||||
t.datetime "reverse_geocoded_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.geography "lonlat", limit: {srid: 4326, type: "st_point", geographic: true}
|
||||
t.index ["lonlat"], name: "index_places_on_lonlat", using: :gist
|
||||
create_table 'places', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.decimal 'longitude', precision: 10, scale: 6, null: false
|
||||
t.decimal 'latitude', precision: 10, scale: 6, null: false
|
||||
t.string 'city'
|
||||
t.string 'country'
|
||||
t.integer 'source', default: 0
|
||||
t.jsonb 'geodata', default: {}, null: false
|
||||
t.datetime 'reverse_geocoded_at'
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.geography 'lonlat', limit: { srid: 4326, type: 'st_point', geographic: true }
|
||||
t.index ['lonlat'], name: 'index_places_on_lonlat', using: :gist
|
||||
end
|
||||
|
||||
create_table "points", force: :cascade do |t|
|
||||
t.integer "battery_status"
|
||||
t.string "ping"
|
||||
t.integer "battery"
|
||||
t.string "tracker_id"
|
||||
t.string "topic"
|
||||
t.integer "altitude"
|
||||
t.decimal "longitude", precision: 10, scale: 6
|
||||
t.string "velocity"
|
||||
t.integer "trigger"
|
||||
t.string "bssid"
|
||||
t.string "ssid"
|
||||
t.integer "connection"
|
||||
t.integer "vertical_accuracy"
|
||||
t.integer "accuracy"
|
||||
t.integer "timestamp"
|
||||
t.decimal "latitude", precision: 10, scale: 6
|
||||
t.integer "mode"
|
||||
t.text "inrids", default: [], array: true
|
||||
t.text "in_regions", default: [], array: true
|
||||
t.jsonb "raw_data", default: {}
|
||||
t.bigint "import_id"
|
||||
t.string "city"
|
||||
t.string "country"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id"
|
||||
t.jsonb "geodata", default: {}, null: false
|
||||
t.bigint "visit_id"
|
||||
t.datetime "reverse_geocoded_at"
|
||||
t.decimal "course", precision: 8, scale: 5
|
||||
t.decimal "course_accuracy", precision: 8, scale: 5
|
||||
t.string "external_track_id"
|
||||
t.geography "lonlat", limit: {srid: 4326, type: "st_point", geographic: true}
|
||||
t.index ["altitude"], name: "index_points_on_altitude"
|
||||
t.index ["battery"], name: "index_points_on_battery"
|
||||
t.index ["battery_status"], name: "index_points_on_battery_status"
|
||||
t.index ["city"], name: "index_points_on_city"
|
||||
t.index ["connection"], name: "index_points_on_connection"
|
||||
t.index ["country"], name: "index_points_on_country"
|
||||
t.index ["external_track_id"], name: "index_points_on_external_track_id"
|
||||
t.index ["geodata"], name: "index_points_on_geodata", using: :gin
|
||||
t.index ["import_id"], name: "index_points_on_import_id"
|
||||
t.index ["latitude", "longitude"], name: "index_points_on_latitude_and_longitude"
|
||||
t.index ["lonlat", "timestamp", "user_id"], name: "index_points_on_lonlat_timestamp_user_id", unique: true
|
||||
t.index ["lonlat"], name: "index_points_on_lonlat", using: :gist
|
||||
t.index ["reverse_geocoded_at"], name: "index_points_on_reverse_geocoded_at"
|
||||
t.index ["timestamp"], name: "index_points_on_timestamp"
|
||||
t.index ["trigger"], name: "index_points_on_trigger"
|
||||
t.index ["user_id"], name: "index_points_on_user_id"
|
||||
t.index ["visit_id"], name: "index_points_on_visit_id"
|
||||
create_table 'points', force: :cascade do |t|
|
||||
t.integer 'battery_status'
|
||||
t.string 'ping'
|
||||
t.integer 'battery'
|
||||
t.string 'tracker_id'
|
||||
t.string 'topic'
|
||||
t.integer 'altitude'
|
||||
t.decimal 'longitude', precision: 10, scale: 6
|
||||
t.string 'velocity'
|
||||
t.integer 'trigger'
|
||||
t.string 'bssid'
|
||||
t.string 'ssid'
|
||||
t.integer 'connection'
|
||||
t.integer 'vertical_accuracy'
|
||||
t.integer 'accuracy'
|
||||
t.integer 'timestamp'
|
||||
t.decimal 'latitude', precision: 10, scale: 6
|
||||
t.integer 'mode'
|
||||
t.text 'inrids', default: [], array: true
|
||||
t.text 'in_regions', default: [], array: true
|
||||
t.jsonb 'raw_data', default: {}
|
||||
t.bigint 'import_id'
|
||||
t.string 'city'
|
||||
t.string 'country'
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.bigint 'user_id'
|
||||
t.jsonb 'geodata', default: {}, null: false
|
||||
t.bigint 'visit_id'
|
||||
t.datetime 'reverse_geocoded_at'
|
||||
t.decimal 'course', precision: 8, scale: 5
|
||||
t.decimal 'course_accuracy', precision: 8, scale: 5
|
||||
t.string 'external_track_id'
|
||||
t.geography 'lonlat', limit: { srid: 4326, type: 'st_point', geographic: true }
|
||||
t.index ['altitude'], name: 'index_points_on_altitude'
|
||||
t.index ['battery'], name: 'index_points_on_battery'
|
||||
t.index ['battery_status'], name: 'index_points_on_battery_status'
|
||||
t.index ['city'], name: 'index_points_on_city'
|
||||
t.index ['connection'], name: 'index_points_on_connection'
|
||||
t.index ['country'], name: 'index_points_on_country'
|
||||
t.index ['external_track_id'], name: 'index_points_on_external_track_id'
|
||||
t.index ['geodata'], name: 'index_points_on_geodata', using: :gin
|
||||
t.index ['import_id'], name: 'index_points_on_import_id'
|
||||
t.index %w[latitude longitude], name: 'index_points_on_latitude_and_longitude'
|
||||
t.index %w[lonlat timestamp user_id], name: 'index_points_on_lonlat_timestamp_user_id', unique: true
|
||||
t.index ['lonlat'], name: 'index_points_on_lonlat', using: :gist
|
||||
t.index ['reverse_geocoded_at'], name: 'index_points_on_reverse_geocoded_at'
|
||||
t.index ['timestamp'], name: 'index_points_on_timestamp'
|
||||
t.index ['trigger'], name: 'index_points_on_trigger'
|
||||
t.index ['user_id'], name: 'index_points_on_user_id'
|
||||
t.index ['visit_id'], name: 'index_points_on_visit_id'
|
||||
end
|
||||
|
||||
create_table "stats", force: :cascade do |t|
|
||||
t.integer "year", null: false
|
||||
t.integer "month", null: false
|
||||
t.integer "distance", null: false
|
||||
t.jsonb "toponyms"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.jsonb "daily_distance", default: {}
|
||||
t.index ["distance"], name: "index_stats_on_distance"
|
||||
t.index ["month"], name: "index_stats_on_month"
|
||||
t.index ["user_id"], name: "index_stats_on_user_id"
|
||||
t.index ["year"], name: "index_stats_on_year"
|
||||
create_table 'stats', force: :cascade do |t|
|
||||
t.integer 'year', null: false
|
||||
t.integer 'month', null: false
|
||||
t.integer 'distance', null: false
|
||||
t.jsonb 'toponyms'
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.bigint 'user_id', null: false
|
||||
t.jsonb 'daily_distance', default: {}
|
||||
t.index ['distance'], name: 'index_stats_on_distance'
|
||||
t.index ['month'], name: 'index_stats_on_month'
|
||||
t.index ['user_id'], name: 'index_stats_on_user_id'
|
||||
t.index ['year'], name: 'index_stats_on_year'
|
||||
end
|
||||
|
||||
create_table "trips", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.datetime "started_at", null: false
|
||||
t.datetime "ended_at", null: false
|
||||
t.integer "distance"
|
||||
t.bigint "user_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.geometry "path", limit: {srid: 3857, type: "line_string"}
|
||||
t.index ["user_id"], name: "index_trips_on_user_id"
|
||||
create_table 'trips', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.datetime 'started_at', null: false
|
||||
t.datetime 'ended_at', null: false
|
||||
t.integer 'distance'
|
||||
t.bigint 'user_id', null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.geometry 'path', limit: { srid: 3857, type: 'line_string' }
|
||||
t.index ['user_id'], name: 'index_trips_on_user_id'
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "api_key", default: "", null: false
|
||||
t.string "theme", default: "dark", null: false
|
||||
t.jsonb "settings", default: {"fog_of_war_meters" => "100", "meters_between_routes" => "1000", "minutes_between_routes" => "60"}
|
||||
t.boolean "admin", default: false
|
||||
t.integer "sign_in_count", default: 0, null: false
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.integer "status", default: 0
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
create_table 'users', force: :cascade do |t|
|
||||
t.string 'email', default: '', null: false
|
||||
t.string 'encrypted_password', default: '', null: false
|
||||
t.string 'reset_password_token'
|
||||
t.datetime 'reset_password_sent_at'
|
||||
t.datetime 'remember_created_at'
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.string 'api_key', default: '', null: false
|
||||
t.string 'theme', default: 'dark', null: false
|
||||
t.jsonb 'settings',
|
||||
default: { 'fog_of_war_meters' => '100', 'meters_between_routes' => '1000',
|
||||
'minutes_between_routes' => '60' }
|
||||
t.boolean 'admin', default: false
|
||||
t.integer 'sign_in_count', default: 0, null: false
|
||||
t.datetime 'current_sign_in_at'
|
||||
t.datetime 'last_sign_in_at'
|
||||
t.string 'current_sign_in_ip'
|
||||
t.string 'last_sign_in_ip'
|
||||
t.integer 'status', default: 0
|
||||
t.datetime 'active_until'
|
||||
t.index ['email'], name: 'index_users_on_email', unique: true
|
||||
t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
|
||||
end
|
||||
|
||||
add_check_constraint "users", "admin IS NOT NULL", name: "users_admin_null", validate: false
|
||||
add_check_constraint 'users', 'admin IS NOT NULL', name: 'users_admin_null', validate: false
|
||||
|
||||
create_table "visits", force: :cascade do |t|
|
||||
t.bigint "area_id"
|
||||
t.bigint "user_id", null: false
|
||||
t.datetime "started_at", null: false
|
||||
t.datetime "ended_at", null: false
|
||||
t.integer "duration", null: false
|
||||
t.string "name", null: false
|
||||
t.integer "status", default: 0, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "place_id"
|
||||
t.index ["area_id"], name: "index_visits_on_area_id"
|
||||
t.index ["place_id"], name: "index_visits_on_place_id"
|
||||
t.index ["started_at"], name: "index_visits_on_started_at"
|
||||
t.index ["user_id"], name: "index_visits_on_user_id"
|
||||
create_table 'visits', force: :cascade do |t|
|
||||
t.bigint 'area_id'
|
||||
t.bigint 'user_id', null: false
|
||||
t.datetime 'started_at', null: false
|
||||
t.datetime 'ended_at', null: false
|
||||
t.integer 'duration', null: false
|
||||
t.string 'name', null: false
|
||||
t.integer 'status', default: 0, null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.bigint 'place_id'
|
||||
t.index ['area_id'], name: 'index_visits_on_area_id'
|
||||
t.index ['place_id'], name: 'index_visits_on_place_id'
|
||||
t.index ['started_at'], name: 'index_visits_on_started_at'
|
||||
t.index ['user_id'], name: 'index_visits_on_user_id'
|
||||
end
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "areas", "users"
|
||||
add_foreign_key "notifications", "users"
|
||||
add_foreign_key "place_visits", "places"
|
||||
add_foreign_key "place_visits", "visits"
|
||||
add_foreign_key "points", "users"
|
||||
add_foreign_key "points", "visits"
|
||||
add_foreign_key "stats", "users"
|
||||
add_foreign_key "trips", "users"
|
||||
add_foreign_key "visits", "areas"
|
||||
add_foreign_key "visits", "places"
|
||||
add_foreign_key "visits", "users"
|
||||
add_foreign_key 'active_storage_attachments', 'active_storage_blobs', column: 'blob_id'
|
||||
add_foreign_key 'active_storage_variant_records', 'active_storage_blobs', column: 'blob_id'
|
||||
add_foreign_key 'areas', 'users'
|
||||
add_foreign_key 'notifications', 'users'
|
||||
add_foreign_key 'place_visits', 'places'
|
||||
add_foreign_key 'place_visits', 'visits'
|
||||
add_foreign_key 'points', 'users'
|
||||
add_foreign_key 'points', 'visits'
|
||||
add_foreign_key 'stats', 'users'
|
||||
add_foreign_key 'trips', 'users'
|
||||
add_foreign_key 'visits', 'areas'
|
||||
add_foreign_key 'visits', 'places'
|
||||
add_foreign_key 'visits', 'users'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ FactoryBot.define do
|
|||
end
|
||||
|
||||
status { :active }
|
||||
active_until { 1000.years.from_now }
|
||||
|
||||
password { SecureRandom.hex(8) }
|
||||
|
||||
|
|
@ -25,6 +26,11 @@ FactoryBot.define do
|
|||
admin { true }
|
||||
end
|
||||
|
||||
trait :inactive do
|
||||
status { :inactive }
|
||||
active_until { 1.day.ago }
|
||||
end
|
||||
|
||||
trait :with_immich_integration do
|
||||
settings do
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ RSpec.describe User, type: :model do
|
|||
|
||||
describe '#activate' do
|
||||
context 'when self-hosted' do
|
||||
let!(:user) { create(:user, status: :inactive) }
|
||||
let!(:user) { create(:user, status: :inactive, active_until: 1.day.ago) }
|
||||
|
||||
before do
|
||||
allow(DawarichSettings).to receive(:self_hosted?).and_return(true)
|
||||
|
|
@ -39,19 +39,20 @@ RSpec.describe User, type: :model do
|
|||
|
||||
it 'activates user after creation' do
|
||||
expect(user.active?).to be_truthy
|
||||
expect(user.active_until).to be_within(1.minute).of(1000.years.from_now)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not self-hosted' do
|
||||
let!(:user) { create(:user, status: :inactive) }
|
||||
|
||||
before do
|
||||
stub_const('SELF_HOSTED', false)
|
||||
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
|
||||
end
|
||||
|
||||
xit 'does not activate user' do
|
||||
it 'does not activate user' do
|
||||
user = create(:user, status: :inactive, active_until: 1.day.ago)
|
||||
|
||||
expect(user.active?).to be_falsey
|
||||
expect(user.active_until).to be_within(1.minute).of(1.day.ago)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ RSpec.describe 'Api::V1::Overland::Batches', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns http unauthorized' do
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ RSpec.describe 'Api::V1::Owntracks::Points', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns http unauthorized' do
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns an unauthorized response' do
|
||||
|
|
@ -150,7 +150,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns an unauthorized response' do
|
||||
|
|
@ -171,7 +171,7 @@ RSpec.describe 'Api::V1::Points', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns an unauthorized response' do
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ RSpec.describe 'Api::V1::Settings', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns http unauthorized' do
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ RSpec.describe 'Settings', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'redirects to the root path' do
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ RSpec.describe '/stats', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns an unauthorized response' do
|
||||
|
|
@ -99,7 +99,7 @@ RSpec.describe '/stats', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'returns an unauthorized response' do
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ RSpec.describe '/trips', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'redirects to the root path' do
|
||||
|
|
@ -93,7 +93,7 @@ RSpec.describe '/trips', type: :request do
|
|||
|
||||
context 'when user is inactive' do
|
||||
before do
|
||||
user.update(status: :inactive)
|
||||
user.update(status: :inactive, active_until: 1.day.ago)
|
||||
end
|
||||
|
||||
it 'redirects to the root path' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue