From: Tom Hughes Date: Sun, 9 Jun 2024 14:37:17 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/4883' X-Git-Tag: live~955 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/63a323dbe3e57ef671737a3eb163acf41f74ef30?hp=eeb7e02f8864f14e30510b9305d706276342e69a Merge remote-tracking branch 'upstream/pull/4883' --- diff --git a/app/assets/images/routing-sprite.svg b/app/assets/images/routing-sprite.svg index e03a1bb84..97701d5a8 100644 --- a/app/assets/images/routing-sprite.svg +++ b/app/assets/images/routing-sprite.svg @@ -1,37 +1,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/assets/javascripts/index/directions/fossgis_valhalla.js b/app/assets/javascripts/index/directions/fossgis_valhalla.js index d44dbd12b..619f8f1e3 100644 --- a/app/assets/javascripts/index/directions/fossgis_valhalla.js +++ b/app/assets/javascripts/index/directions/fossgis_valhalla.js @@ -27,7 +27,7 @@ function FOSSGISValhallaEngine(id, costing) { 5, // kStayLeft = 24; 20, // kMerge = 25; 10, // kRoundaboutEnter = 26; - 11, // kRoundaboutExit = 27; + 10, // kRoundaboutExit = 27; 17, // kFerryEnter = 28; 0, // kFerryExit = 29; null, // kTransit = 30; diff --git a/app/assets/javascripts/richtext.js b/app/assets/javascripts/richtext.js index ea2efcfad..3036f169b 100644 --- a/app/assets/javascripts/richtext.js +++ b/app/assets/javascripts/richtext.js @@ -41,7 +41,6 @@ $(document).ready(function () { $(".richtext_dopreview").click(function (event) { var editor = $(this).parents(".richtext_container").find("textarea"); var preview = $(this).parents(".richtext_container").find(".richtext_preview"); - var width = editor.outerWidth() - preview.outerWidth() + preview.width(); var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height(); if (preview.contents().length === 0) { @@ -56,7 +55,6 @@ $(document).ready(function () { } editor.hide(); - preview.width(width); preview.css("min-height", minHeight + "px"); preview.show(); diff --git a/app/models/diary_comment.rb b/app/models/diary_comment.rb index 55d2c3c84..a88c69f12 100644 --- a/app/models/diary_comment.rb +++ b/app/models/diary_comment.rb @@ -23,7 +23,7 @@ # class DiaryComment < ApplicationRecord - belongs_to :user + belongs_to :user, :counter_cache => true belongs_to :diary_entry scope :visible, -> { where(:visible => true) } diff --git a/app/models/note_comment.rb b/app/models/note_comment.rb index b870e5558..d318c5e95 100644 --- a/app/models/note_comment.rb +++ b/app/models/note_comment.rb @@ -26,7 +26,7 @@ class NoteComment < ApplicationRecord belongs_to :note, :touch => true - belongs_to :author, :class_name => "User", :optional => true + belongs_to :author, :class_name => "User", :optional => true, :counter_cache => true validates :id, :uniqueness => true, :presence => { :on => :update }, :numericality => { :on => :update, :only_integer => true } diff --git a/app/models/user.rb b/app/models/user.rb index e4067a350..4241a9e56 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,35 +2,37 @@ # # Table name: users # -# email :string not null -# id :bigint(8) not null, primary key -# pass_crypt :string not null -# creation_time :datetime not null -# display_name :string default(""), not null -# data_public :boolean default(FALSE), not null -# description :text default(""), not null -# home_lat :float -# home_lon :float -# home_zoom :integer default(3) -# pass_salt :string -# email_valid :boolean default(FALSE), not null -# new_email :string -# creation_ip :string -# languages :string -# status :enum default("pending"), not null -# terms_agreed :datetime -# consider_pd :boolean default(FALSE), not null -# auth_uid :string -# preferred_editor :string -# terms_seen :boolean default(FALSE), not null -# description_format :enum default("markdown"), not null -# changesets_count :integer default(0), not null -# traces_count :integer default(0), not null -# diary_entries_count :integer default(0), not null -# image_use_gravatar :boolean default(FALSE), not null -# auth_provider :string -# home_tile :bigint(8) -# tou_agreed :datetime +# email :string not null +# id :bigint(8) not null, primary key +# pass_crypt :string not null +# creation_time :datetime not null +# display_name :string default(""), not null +# data_public :boolean default(FALSE), not null +# description :text default(""), not null +# home_lat :float +# home_lon :float +# home_zoom :integer default(3) +# pass_salt :string +# email_valid :boolean default(FALSE), not null +# new_email :string +# creation_ip :string +# languages :string +# status :enum default("pending"), not null +# terms_agreed :datetime +# consider_pd :boolean default(FALSE), not null +# auth_uid :string +# preferred_editor :string +# terms_seen :boolean default(FALSE), not null +# description_format :enum default("markdown"), not null +# changesets_count :integer default(0), not null +# traces_count :integer default(0), not null +# diary_entries_count :integer default(0), not null +# image_use_gravatar :boolean default(FALSE), not null +# auth_provider :string +# home_tile :bigint(8) +# tou_agreed :datetime +# diary_comments_count :integer default(0) +# note_comments_count :integer default(0) # # Indexes # diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 2c40cfebe..c73581b25 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -14,7 +14,8 @@ <%= number_with_delimiter(current_user.changesets.size) %>
  • - <%= link_to t(".my notes"), user_notes_path(@user) %> + <%= link_to t(".my notes"), user_notes_path(current_user) %> + <%= number_with_delimiter(current_user.note_comments.size) %>
  • <%= link_to t(".my traces"), :controller => "traces", :action => "mine" %> @@ -26,6 +27,7 @@
  • <%= link_to t(".my comments"), diary_comments_path(current_user) %> + <%= number_with_delimiter(current_user.diary_comments.size) %>
  • <%= link_to t(".my settings"), edit_account_path %> @@ -59,6 +61,7 @@
  • <%= link_to t(".notes"), user_notes_path(@user) %> + <%= number_with_delimiter(@user.note_comments.size) %>
  • <%= link_to t(".traces"), :controller => "traces", :action => "index", :display_name => @user.display_name %> @@ -76,6 +79,7 @@
  • <%= link_to t(".comments"), diary_comments_path(@user) %> + <%= number_with_delimiter(@user.diary_comments.size) %>
  • <% if current_user and current_user.friends_with?(@user) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 1da263d77..32ecbf7cd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2173,9 +2173,6 @@ en: index: js_1: "You are either using a browser that does not support JavaScript, or you have disabled JavaScript." js_2: "OpenStreetMap uses JavaScript for its slippy map." - permalink: Permalink - shortlink: Shortlink - createnote: Add a note license: copyright: "Copyright OpenStreetMap and contributors, under an open license" license_url: "https://openstreetmap.org/copyright" diff --git a/db/migrate/20240605134916_add_notes_and_diary_comments_counter_caches.rb b/db/migrate/20240605134916_add_notes_and_diary_comments_counter_caches.rb new file mode 100644 index 000000000..d90521595 --- /dev/null +++ b/db/migrate/20240605134916_add_notes_and_diary_comments_counter_caches.rb @@ -0,0 +1,21 @@ +class AddNotesAndDiaryCommentsCounterCaches < ActiveRecord::Migration[7.1] + def self.up + add_column :users, :diary_comments_count, :integer, :default => 0 + add_column :users, :note_comments_count, :integer, :default => 0 + + users_with_diary_comments = DiaryComment.distinct.pluck(:user_id) + users_with_diary_comments.each do |user_id| + User.reset_counters(user_id, :diary_comments) + end + + users_with_note_comments = NoteComment.where.not(:author_id => nil).distinct.pluck(:author_id) + users_with_note_comments.each do |author_id| + User.reset_counters(author_id, :note_comments) + end + end + + def self.down + remove_column :users, :diary_comments_count + remove_column :users, :note_comments_count + end +end diff --git a/db/structure.sql b/db/structure.sql index 829595e7c..2e8bdbb61 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1565,7 +1565,9 @@ CREATE TABLE public.users ( image_use_gravatar boolean DEFAULT false NOT NULL, auth_provider character varying, home_tile bigint, - tou_agreed timestamp without time zone + tou_agreed timestamp without time zone, + diary_comments_count integer DEFAULT 0, + note_comments_count integer DEFAULT 0 ); @@ -3519,6 +3521,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('23'), ('22'), ('21'), +('20240605134916'), ('20240405083825'), ('20240307181018'), ('20240307180830'),