From cc0a55cf9aead00e1cb044649f84c2187e0e4a35 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 18 Aug 2019 03:45:51 +0200 Subject: Add more accurate hashtag search (#11579) * Add more accurate hashtag search Using ElasticSearch to index hashtags with edge n-grams and score them by usage within the last 7 days since last activity. Only hashtags that have been reviewed and are listable can appear in searches, unless they match the query exactly * Fix search analyzer dropping non-ascii characters --- db/migrate/20190815225426_add_last_status_at_to_tags.rb | 6 ++++++ db/schema.rb | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190815225426_add_last_status_at_to_tags.rb (limited to 'db') diff --git a/db/migrate/20190815225426_add_last_status_at_to_tags.rb b/db/migrate/20190815225426_add_last_status_at_to_tags.rb new file mode 100644 index 000000000..d83537c47 --- /dev/null +++ b/db/migrate/20190815225426_add_last_status_at_to_tags.rb @@ -0,0 +1,6 @@ +class AddLastStatusAtToTags < ActiveRecord::Migration[5.2] + def change + add_column :tags, :last_status_at, :datetime + add_column :tags, :last_trend_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index f8fc6a821..0da20d62f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_08_07_135426) do +ActiveRecord::Schema.define(version: 2019_08_15_225426) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -667,6 +667,8 @@ ActiveRecord::Schema.define(version: 2019_08_07_135426) do t.boolean "listable" t.datetime "reviewed_at" t.datetime "requested_review_at" + t.datetime "last_status_at" + t.datetime "last_trend_at" t.index "lower((name)::text)", name: "index_tags_on_name_lower", unique: true end -- cgit From cb62a83a71a9679061f8daa468119124b5da5e76 Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 19 Aug 2019 11:40:42 +0200 Subject: Add invite comments (#10465) --- app/controllers/invites_controller.rb | 2 +- app/models/invite.rb | 3 +++ app/views/invites/_form.html.haml | 3 +++ app/views/invites/_invite.html.haml | 3 +++ app/views/invites/index.html.haml | 1 + db/migrate/20190403141604_add_comment_to_invites.rb | 5 +++++ db/schema.rb | 1 + 7 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190403141604_add_comment_to_invites.rb (limited to 'db') diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index de5280305..8d92147e2 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -43,7 +43,7 @@ class InvitesController < ApplicationController end def resource_params - params.require(:invite).permit(:max_uses, :expires_in, :autofollow) + params.require(:invite).permit(:max_uses, :expires_in, :autofollow, :comment) end def set_body_classes diff --git a/app/models/invite.rb b/app/models/invite.rb index 02ab8e0b2..29d25eae8 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -12,6 +12,7 @@ # created_at :datetime not null # updated_at :datetime not null # autofollow :boolean default(FALSE), not null +# comment :text # class Invite < ApplicationRecord @@ -22,6 +23,8 @@ class Invite < ApplicationRecord scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) } + validates :comment, length: { maximum: 420 } + before_validation :set_code def valid_for_use? diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml index 3a2a5ef0e..b19f70539 100644 --- a/app/views/invites/_form.html.haml +++ b/app/views/invites/_form.html.haml @@ -10,5 +10,8 @@ .fields-group = f.input :autofollow, wrapper: :with_label + .fields-group + = f.input :comment, wrapper: :with_label, input_html: { maxlength: 420 } + .actions = f.button :button, t('invites.generate'), type: :submit diff --git a/app/views/invites/_invite.html.haml b/app/views/invites/_invite.html.haml index 62799ca5b..03050c868 100644 --- a/app/views/invites/_invite.html.haml +++ b/app/views/invites/_invite.html.haml @@ -20,6 +20,9 @@ %td{ colspan: 2 } = t('invites.expired') + %td + = invite.comment + %td - if invite.valid_for_use? && policy(invite).destroy? = table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete diff --git a/app/views/invites/index.html.haml b/app/views/invites/index.html.haml index 61420ab1e..62065d6ae 100644 --- a/app/views/invites/index.html.haml +++ b/app/views/invites/index.html.haml @@ -15,6 +15,7 @@ %th %th= t('invites.table.uses') %th= t('invites.table.expires_at') + %th= t('invites.table.comment') %th %tbody = render @invites diff --git a/db/migrate/20190403141604_add_comment_to_invites.rb b/db/migrate/20190403141604_add_comment_to_invites.rb new file mode 100644 index 000000000..f0d7b1dcd --- /dev/null +++ b/db/migrate/20190403141604_add_comment_to_invites.rb @@ -0,0 +1,5 @@ +class AddCommentToInvites < ActiveRecord::Migration[5.2] + def change + add_column :invites, :comment, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 0da20d62f..18f615d61 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -344,6 +344,7 @@ ActiveRecord::Schema.define(version: 2019_08_15_225426) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.boolean "autofollow", default: false, null: false + t.text "comment" t.index ["code"], name: "index_invites_on_code", unique: true t.index ["user_id"], name: "index_invites_on_user_id" end -- cgit