Skip to content

Commit 4ffd2f3

Browse files
authored
Merge pull request #1244 from ruby-china/fix-for-3.8
Fix for 3.8
2 parents e96ffc1 + e8f68f7 commit 4ffd2f3

File tree

12 files changed

+91
-155
lines changed

12 files changed

+91
-155
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ RUN mkdir -p /home/app &&\
1414
rm -rf /etc/nginx/conf.d/default.conf
1515

1616
ADD Gemfile Gemfile.lock package.json yarn.lock /home/app/homeland/
17-
RUN gem install puma
1817
RUN bundle config set deployment 'true' && bundle install && yarn &&\
1918
find /home/app/homeland/vendor/bundle -name tmp -type d -exec rm -rf {} +
2019
ADD . /home/app/homeland

app/helpers/topics_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def topic_follow_tag(topic, opts = {})
3030
if opts[:class].present?
3131
class_name += " " + opts[:class]
3232
end
33-
icon = content_tag("i", "", class: "fa fa-eye")
33+
icon = content_tag("i", "", class: "fa fa-bell")
3434
link_to(raw("#{icon} 订阅"), "#", "data-id" => topic.id, class: class_name)
3535
end
3636

app/views/shared/_editor_toolbar.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<% end %>
1717
<a id="editor-upload-image" href="#" title="<%= t("common.editor_add_image") %>" class="nav-link upload-button">
1818
<i class="upload-icon fa fa-image"></i>
19-
<i class='loading fa fa-circle-o-notch fa-spin'></i>
19+
<i class='loading fa fa-circle-notch fa-spin'></i>
2020
</a>
2121
<a href="#" class="nav-link preview" title="<%= t("common.editor_toolbar_preview") %>">
2222
<%= icon_tag("eye") %>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class RemoveFollowerIdsFromUsers < ActiveRecord::Migration[6.1]
2+
def change
3+
# Remove unused Array fields, they were instead by ActionStore
4+
# ref: https://github.com/ruby-china/homeland/pull/857
5+
remove_column :users, :follower_ids
6+
end
7+
end

db/schema.rb

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2020_11_19_010515) do
13+
ActiveRecord::Schema.define(version: 2020_12_21_082655) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -37,6 +37,14 @@
3737
t.index ["provider", "uid"], name: "index_authorizations_on_provider_and_uid"
3838
end
3939

40+
create_table "commentable_pages", force: :cascade do |t|
41+
t.string "name"
42+
t.integer "user_id"
43+
t.integer "comments_count", default: 0, null: false
44+
t.datetime "created_at", precision: 6, null: false
45+
t.datetime "updated_at", precision: 6, null: false
46+
end
47+
4048
create_table "comments", id: :serial, force: :cascade do |t|
4149
t.text "body", null: false
4250
t.integer "user_id", null: false
@@ -75,6 +83,14 @@
7583
t.index ["name"], name: "index_locations_on_name"
7684
end
7785

86+
create_table "monkeys", force: :cascade do |t|
87+
t.string "name"
88+
t.integer "user_id"
89+
t.integer "comments_count"
90+
t.datetime "created_at", precision: 6, null: false
91+
t.datetime "updated_at", precision: 6, null: false
92+
end
93+
7894
create_table "nodes", id: :serial, force: :cascade do |t|
7995
t.string "name", null: false
8096
t.string "summary"
@@ -283,6 +299,15 @@
283299
t.index ["user_id"], name: "index_team_users_on_user_id"
284300
end
285301

302+
create_table "test_documents", force: :cascade do |t|
303+
t.integer "user_id"
304+
t.integer "reply_to_id"
305+
t.integer "mentioned_user_ids", default: [], array: true
306+
t.text "body"
307+
t.datetime "created_at", precision: 6, null: false
308+
t.datetime "updated_at", precision: 6, null: false
309+
end
310+
286311
create_table "topics", id: :serial, force: :cascade do |t|
287312
t.integer "user_id", null: false
288313
t.integer "node_id", null: false
@@ -362,7 +387,6 @@
362387
t.string "perishable_token", default: "", null: false
363388
t.integer "topics_count", default: 0, null: false
364389
t.integer "replies_count", default: 0, null: false
365-
t.integer "follower_ids", default: [], array: true
366390
t.string "type", limit: 20
367391
t.integer "failed_attempts", default: 0, null: false
368392
t.string "unlock_token"
@@ -378,4 +402,12 @@
378402
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
379403
end
380404

405+
create_table "walking_deads", force: :cascade do |t|
406+
t.string "name"
407+
t.string "tag"
408+
t.datetime "deleted_at"
409+
t.datetime "created_at", precision: 6, null: false
410+
t.datetime "updated_at", precision: 6, null: false
411+
end
412+
381413
end

lib/homeland.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
require "homeland/version"
44
require "homeland/plugin"
55

6+
unless ENV["RAILS_PRECOMPILE"]
7+
# Preload Jieba
8+
require "homeland/search"
9+
end
10+
611
module Homeland
712
cattr_reader :boot_at
813

lib/homeland/search.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Search
55
attr_accessor :term, :terms
66

77
INVALID_CHARS = /[:()&!'"]/
8+
JIEBA = JiebaRb::Segment.new
89

910
def initialize(term)
1011
term = term.to_s.squish.gsub(INVALID_CHARS, "")
@@ -24,9 +25,7 @@ def query_results
2425

2526
class << self
2627
def jieba
27-
return @jieba if defined? @jieba
28-
29-
@jieba = JiebaRb::Segment.new
28+
JIEBA
3029
end
3130
end
3231

lib/homeland/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Homeland
44
class << self
55
def version
6-
"3.8.0"
6+
"3.8.1"
77
end
88
end
99
end

lib/tasks/memory.rake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
task memory: :environment do
4+
require "homeland"
5+
include ApplicationHelper
6+
include ActionView::Helpers::OutputSafetyHelper
7+
include ActionView::Helpers::TextHelper
8+
9+
str = Homeland::Markdown.example
10+
11+
a = []
12+
13+
puts "Starting to profile memory..."
14+
b = {}
15+
puts "Before =>"
16+
print_memory
17+
18+
count = 5_000_000
19+
step = (count / 100).to_i
20+
count.times do |i|
21+
sanitize_markdown(Homeland::Markdown.call(str))
22+
23+
if i % step == 0
24+
print_memory
25+
end
26+
end
27+
28+
print_memory
29+
puts GC.start
30+
puts "After GC"
31+
print_memory
32+
end
33+
34+
def print_memory
35+
rss = (`ps -eo pid,rss | grep #{Process.pid} | awk '{print $2}'`.to_i / 1024.0).round(1)
36+
puts "rss: #{rss}mb live objects #{GC.stat[:heap_live_slots]}"
37+
end

lib/tasks/upgrade/next.rake

Lines changed: 0 additions & 143 deletions
This file was deleted.

test/helpers/topics_helper_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class TopicsHelperTest < ActionView::TestCase
5555
assert_equal "", topic_follow_tag(nil)
5656

5757
# was unfollow
58-
assert_equal "<a data-id=\"#{topic.id}\" class=\"follow\" href=\"#\"><i class=\"fa fa-eye\"></i> 订阅</a>", topic_follow_tag(topic)
58+
assert_html_equal %(<a data-id="#{topic.id}" class="follow" href="#"><i class="fa fa-bell"></i> 订阅</a>), topic_follow_tag(topic)
5959

6060
# was active
6161
user.stub(:follow_topic?, true) do
62-
assert_equal "<a data-id=\"#{topic.id}\" class=\"follow active\" href=\"#\"><i class=\"fa fa-eye\"></i> 订阅</a>", topic_follow_tag(topic)
62+
assert_html_equal %(<a data-id="#{topic.id}" class="follow active" href="#"><i class="fa fa-bell"></i> 订阅</a>), topic_follow_tag(topic)
6363
end
6464
end
6565

test/models/reply_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class ReplyTest < ActiveSupport::TestCase
225225

226226
test ".notification_receiver_ids" do
227227
mentioned_user_ids = [1, 2, 3]
228-
user = create(:user, follower_ids: [2, 3, 5, 7, 9])
228+
user = create(:user)
229229
topic = create(:topic, user_id: 10)
230230
reply = create(:reply, user: user, topic: topic, mentioned_user_ids: mentioned_user_ids)
231231

0 commit comments

Comments
 (0)