Story: rename expired -> deleted to match usage
This commit is contained in:
parent
0ef4f8cd17
commit
dba88ba6c8
|
@ -871,10 +871,10 @@ li.story.saved a.saver {
|
||||||
color: var(--color-fg-affirmative);
|
color: var(--color-fg-affirmative);
|
||||||
}
|
}
|
||||||
|
|
||||||
li.story.expired {
|
li.story.deleted {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
li.story.expired a {
|
li.story.deleted a {
|
||||||
color: var(--color-fg-contrast-5) !important;
|
color: var(--color-fg-contrast-5) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ class CommentsController < ApplicationController
|
||||||
.not_on_story_hidden_by(@user)
|
.not_on_story_hidden_by(@user)
|
||||||
.order("id DESC")
|
.order("id DESC")
|
||||||
.includes(:user, :hat, :story => :user)
|
.includes(:user, :hat, :story => :user)
|
||||||
.joins(:story).where.not(stories: { is_expired: true })
|
.joins(:story).where.not(stories: { is_deleted: true })
|
||||||
.limit(COMMENTS_PER_PAGE)
|
.limit(COMMENTS_PER_PAGE)
|
||||||
.offset((@page - 1) * COMMENTS_PER_PAGE)
|
.offset((@page - 1) * COMMENTS_PER_PAGE)
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ class CommentsController < ApplicationController
|
||||||
.order("id DESC")
|
.order("id DESC")
|
||||||
.includes(:user, :hat, :story => :user)
|
.includes(:user, :hat, :story => :user)
|
||||||
.joins(:votes).where(votes: { user_id: @user.id, vote: 1 })
|
.joins(:votes).where(votes: { user_id: @user.id, vote: 1 })
|
||||||
.joins(:story).where.not(stories: { is_expired: true })
|
.joins(:story).where.not(stories: { is_deleted: true })
|
||||||
.limit(COMMENTS_PER_PAGE)
|
.limit(COMMENTS_PER_PAGE)
|
||||||
.offset((@page - 1) * COMMENTS_PER_PAGE)
|
.offset((@page - 1) * COMMENTS_PER_PAGE)
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ class CommentsController < ApplicationController
|
||||||
comments = Comment.accessible_to_user(@user)
|
comments = Comment.accessible_to_user(@user)
|
||||||
.where(:thread_id => thread_ids)
|
.where(:thread_id => thread_ids)
|
||||||
.includes(:user, :hat, :story => :user, :votes => :user)
|
.includes(:user, :hat, :story => :user, :votes => :user)
|
||||||
.joins(:story).where.not(stories: { is_expired: true })
|
.joins(:story).where.not(stories: { is_deleted: true })
|
||||||
.arrange_for_user(@user)
|
.arrange_for_user(@user)
|
||||||
|
|
||||||
comments_by_thread_id = comments.group_by(&:thread_id)
|
comments_by_thread_id = comments.group_by(&:thread_id)
|
||||||
|
|
|
@ -40,7 +40,7 @@ class StoriesController < ApplicationController
|
||||||
return render :action => "edit"
|
return render :action => "edit"
|
||||||
end
|
end
|
||||||
|
|
||||||
@story.is_expired = true
|
@story.is_deleted = true
|
||||||
@story.editor = @user
|
@story.editor = @user
|
||||||
|
|
||||||
if @story.save(:validate => false)
|
if @story.save(:validate => false)
|
||||||
|
@ -229,7 +229,7 @@ class StoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
update_story_attributes
|
update_story_attributes
|
||||||
@story.is_expired = false
|
@story.is_deleted = false
|
||||||
@story.editor = @user
|
@story.editor = @user
|
||||||
|
|
||||||
if @story.save(:validate => false)
|
if @story.save(:validate => false)
|
||||||
|
@ -245,7 +245,7 @@ class StoriesController < ApplicationController
|
||||||
return redirect_to "/"
|
return redirect_to "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
@story.is_expired = false
|
@story.is_deleted = false
|
||||||
@story.editor = @user
|
@story.editor = @user
|
||||||
update_story_attributes
|
update_story_attributes
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class Search
|
||||||
|
|
||||||
def with_stories_matching_tags(base, tag_scopes)
|
def with_stories_matching_tags(base, tag_scopes)
|
||||||
story_ids_matching_tags = with_tags(
|
story_ids_matching_tags = with_tags(
|
||||||
Story.unmerged.where(:is_expired => false), tag_scopes
|
Story.unmerged.where(is_deleted: false), tag_scopes
|
||||||
).select(:id).map(&:id)
|
).select(:id).map(&:id)
|
||||||
base.where(story_id: story_ids_matching_tags)
|
base.where(story_id: story_ids_matching_tags)
|
||||||
end
|
end
|
||||||
|
@ -102,7 +102,7 @@ class Search
|
||||||
|
|
||||||
case self.what
|
case self.what
|
||||||
when "stories"
|
when "stories"
|
||||||
base = Story.unmerged.where(:is_expired => false)
|
base = Story.unmerged.where(is_deleted: false)
|
||||||
if domain.present?
|
if domain.present?
|
||||||
base = with_stories_in_domain(base, domain)
|
base = with_stories_in_domain(base, domain)
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,8 +40,8 @@ class Story < ApplicationRecord
|
||||||
q = includes(:tags).unmerged
|
q = includes(:tags).unmerged
|
||||||
user && user.is_moderator? ? q : q.not_deleted
|
user && user.is_moderator? ? q : q.not_deleted
|
||||||
}
|
}
|
||||||
scope :deleted, -> { where(is_expired: true) }
|
scope :deleted, -> { where(is_deleted: true) }
|
||||||
scope :not_deleted, -> { where(is_expired: false) }
|
scope :not_deleted, -> { where(is_deleted: false) }
|
||||||
scope :unmerged, -> { where(:merged_story_id => nil) }
|
scope :unmerged, -> { where(:merged_story_id => nil) }
|
||||||
scope :positive_ranked, -> { where("score >= 0") }
|
scope :positive_ranked, -> { where("score >= 0") }
|
||||||
scope :low_scoring, ->(max = 5) { where("score < ?", max) }
|
scope :low_scoring, ->(max = 5) { where("score < ?", max) }
|
||||||
|
@ -269,7 +269,7 @@ class Story < ApplicationRecord
|
||||||
Story
|
Story
|
||||||
.where(:url => urls)
|
.where(:url => urls)
|
||||||
.or(Story.where("url RLIKE ?", urls_with_trailing_pound.join(".|")))
|
.or(Story.where("url RLIKE ?", urls_with_trailing_pound.join(".|")))
|
||||||
.where("is_expired = ? OR is_moderated = ?", false, true)
|
.where("is_deleted = ? OR is_moderated = ?", false, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
# doesn't include deleted/moderated/merged stories
|
# doesn't include deleted/moderated/merged stories
|
||||||
|
@ -563,7 +563,7 @@ class Story < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_gone?
|
def is_gone?
|
||||||
is_expired? || (self.user.is_banned? && score < 0)
|
is_deleted? || (self.user.is_banned? && score < 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_hidden_by_user?(user)
|
def is_hidden_by_user?(user)
|
||||||
|
@ -618,9 +618,9 @@ class Story < ApplicationRecord
|
||||||
m.story_id = self.id
|
m.story_id = self.id
|
||||||
|
|
||||||
m.action = all_changes.map {|k, v|
|
m.action = all_changes.map {|k, v|
|
||||||
if k == "is_expired" && self.is_expired?
|
if k == "is_deleted" && self.is_deleted?
|
||||||
"deleted story"
|
"deleted story"
|
||||||
elsif k == "is_expired" && !self.is_expired?
|
elsif k == "is_deleted" && !self.is_deleted?
|
||||||
"undeleted story"
|
"undeleted story"
|
||||||
elsif k == "merged_story_id"
|
elsif k == "merged_story_id"
|
||||||
if v[1]
|
if v[1]
|
||||||
|
|
|
@ -416,7 +416,7 @@ class User < ApplicationRecord
|
||||||
self.email = "#{self.username}@lobsters.example" if \
|
self.email = "#{self.username}@lobsters.example" if \
|
||||||
self.karma < 0 ||
|
self.karma < 0 ||
|
||||||
(self.comments.where('created_at >= now() - interval 30 day AND is_deleted').count +
|
(self.comments.where('created_at >= now() - interval 30 day AND is_deleted').count +
|
||||||
self.stories.where('created_at >= now() - interval 30 day AND is_expired AND is_moderated')
|
self.stories.where('created_at >= now() - interval 30 day AND is_deleted AND is_moderated')
|
||||||
.count >= 3) ||
|
.count >= 3) ||
|
||||||
FlaggedCommenters.new('90d').check_list_for(self)
|
FlaggedCommenters.new('90d').check_list_for(self)
|
||||||
end
|
end
|
||||||
|
@ -505,7 +505,7 @@ class User < ApplicationRecord
|
||||||
Tag.active.joins(
|
Tag.active.joins(
|
||||||
:stories
|
:stories
|
||||||
).where(
|
).where(
|
||||||
:stories => { :user_id => self.id, :is_expired => false }
|
:stories => { :user_id => self.id, :is_deleted => false }
|
||||||
).group(
|
).group(
|
||||||
Tag.arel_table[:id]
|
Tag.arel_table[:id]
|
||||||
).order(
|
).order(
|
||||||
|
|
|
@ -10,7 +10,7 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %>
|
||||||
<%= story.score <= -5 ? "negative_5" : "" %>
|
<%= story.score <= -5 ? "negative_5" : "" %>
|
||||||
<%= story.is_hidden_by_cur_user ? "hidden" : "" %>
|
<%= story.is_hidden_by_cur_user ? "hidden" : "" %>
|
||||||
<%= story.is_saved_by_cur_user ? "saved" : "" %>
|
<%= story.is_saved_by_cur_user ? "saved" : "" %>
|
||||||
<%= story.is_expired? ? "expired" : "" %>">
|
<%= story.is_deleted? ? "deleted" : "" %>">
|
||||||
<div class="story_liner h-entry">
|
<div class="story_liner h-entry">
|
||||||
<div class="voters">
|
<div class="voters">
|
||||||
<% if @user %>
|
<% if @user %>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class StoriesExpiredToDeleted < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
rename_column :stories, :is_expired, :is_deleted
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2022_01_28_133226) do
|
ActiveRecord::Schema.define(version: 2022_02_07_033514) do
|
||||||
|
|
||||||
create_table "categories", charset: "utf8mb4", force: :cascade do |t|
|
create_table "categories", charset: "utf8mb4", force: :cascade do |t|
|
||||||
t.string "category"
|
t.string "category"
|
||||||
|
@ -191,7 +191,7 @@ ActiveRecord::Schema.define(version: 2022_01_28_133226) do
|
||||||
t.string "title", limit: 150, default: "", null: false
|
t.string "title", limit: 150, default: "", null: false
|
||||||
t.text "description", size: :medium
|
t.text "description", size: :medium
|
||||||
t.string "short_id", limit: 6, default: "", null: false
|
t.string "short_id", limit: 6, default: "", null: false
|
||||||
t.boolean "is_expired", default: false, null: false
|
t.boolean "is_deleted", default: false, null: false
|
||||||
t.integer "score", default: 1, null: false
|
t.integer "score", default: 1, null: false
|
||||||
t.integer "flags", default: 0, null: false, unsigned: true
|
t.integer "flags", default: 0, null: false, unsigned: true
|
||||||
t.boolean "is_moderated", default: false, null: false
|
t.boolean "is_moderated", default: false, null: false
|
||||||
|
@ -208,7 +208,7 @@ ActiveRecord::Schema.define(version: 2022_01_28_133226) do
|
||||||
t.index ["description"], name: "index_stories_on_description", type: :fulltext
|
t.index ["description"], name: "index_stories_on_description", type: :fulltext
|
||||||
t.index ["domain_id"], name: "index_stories_on_domain_id"
|
t.index ["domain_id"], name: "index_stories_on_domain_id"
|
||||||
t.index ["hotness"], name: "hotness_idx"
|
t.index ["hotness"], name: "hotness_idx"
|
||||||
t.index ["id", "is_expired"], name: "index_stories_on_id_and_is_expired"
|
t.index ["id", "is_deleted"], name: "index_stories_on_id_and_is_deleted"
|
||||||
t.index ["merged_story_id"], name: "index_stories_on_merged_story_id"
|
t.index ["merged_story_id"], name: "index_stories_on_merged_story_id"
|
||||||
t.index ["score"], name: "index_stories_on_score"
|
t.index ["score"], name: "index_stories_on_score"
|
||||||
t.index ["short_id"], name: "unique_short_id", unique: true
|
t.index ["short_id"], name: "unique_short_id", unique: true
|
||||||
|
|
|
@ -60,7 +60,7 @@ class FakeDataGenerator
|
||||||
title: title,
|
title: title,
|
||||||
tags_a: [tag.tag],
|
tags_a: [tag.tag],
|
||||||
description: Faker::Lorem.paragraphs(number: 1),
|
description: Faker::Lorem.paragraphs(number: 1),
|
||||||
is_expired: true,
|
is_deleted: true,
|
||||||
editor: user
|
editor: user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ if __FILE__ == $PROGRAM_NAME
|
||||||
|
|
||||||
last_story_id = (Keystore.value_for(LAST_STORY_KEY) || Story.last && Story.last.id).to_i
|
last_story_id = (Keystore.value_for(LAST_STORY_KEY) || Story.last && Story.last.id).to_i
|
||||||
|
|
||||||
Story.where("id > ? AND is_expired = ?", last_story_id, false).order(:id).each do |s|
|
Story.where("id > ? AND is_deleted = ?", last_story_id, false).order(:id).each do |s|
|
||||||
StoryText.fill_cache!(s)
|
StoryText.fill_cache!(s)
|
||||||
|
|
||||||
mailing_list_users.each do |u|
|
mailing_list_users.each do |u|
|
||||||
|
|
|
@ -73,7 +73,7 @@ if __FILE__ == $PROGRAM_NAME
|
||||||
Story.order('id desc').limit(1).offset(1).pluck(:id).try(:first)
|
Story.order('id desc').limit(1).offset(1).pluck(:id).try(:first)
|
||||||
).to_i
|
).to_i
|
||||||
|
|
||||||
Story.where("id > ? AND is_expired = ?", last_story_id, false).order(:id).each do |s|
|
Story.where("id > ? AND is_deleted = ?", last_story_id, false).order(:id).each do |s|
|
||||||
# mark it done so we don't hit them again if we or they crash
|
# mark it done so we don't hit them again if we or they crash
|
||||||
Keystore.put(LAST_STORY_KEY, s.id)
|
Keystore.put(LAST_STORY_KEY, s.id)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ FactoryBot.define do
|
||||||
tags_a { ["tag1", "tag2"] }
|
tags_a { ["tag1", "tag2"] }
|
||||||
|
|
||||||
trait :deleted do
|
trait :deleted do
|
||||||
is_expired { true }
|
is_deleted { true }
|
||||||
editor { user }
|
editor { user }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -112,7 +112,7 @@ RSpec.feature "Submitting Stories", type: :feature do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "resubmitting a recent link deleted by a moderator" do
|
scenario "resubmitting a recent link deleted by a moderator" do
|
||||||
s = create(:story, is_expired: true, is_moderated: true, created_at: 1.day.ago)
|
s = create(:story, is_deleted: true, is_moderated: true, created_at: 1.day.ago)
|
||||||
expect {
|
expect {
|
||||||
visit "/stories/new"
|
visit "/stories/new"
|
||||||
fill_in "URL", with: s.url
|
fill_in "URL", with: s.url
|
||||||
|
|
|
@ -177,7 +177,7 @@ describe 'stores', type: :request do
|
||||||
|
|
||||||
it 'does nothing to deleted comments' do
|
it 'does nothing to deleted comments' do
|
||||||
expect {
|
expect {
|
||||||
target.is_expired = true
|
target.is_deleted = true
|
||||||
target.editor = target.user
|
target.editor = target.user
|
||||||
target.save!
|
target.save!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue