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);
|
||||
}
|
||||
|
||||
li.story.expired {
|
||||
li.story.deleted {
|
||||
opacity: 0.6;
|
||||
}
|
||||
li.story.expired a {
|
||||
li.story.deleted a {
|
||||
color: var(--color-fg-contrast-5) !important;
|
||||
}
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ class CommentsController < ApplicationController
|
|||
.not_on_story_hidden_by(@user)
|
||||
.order("id DESC")
|
||||
.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)
|
||||
.offset((@page - 1) * COMMENTS_PER_PAGE)
|
||||
|
||||
|
@ -300,7 +300,7 @@ class CommentsController < ApplicationController
|
|||
.order("id DESC")
|
||||
.includes(:user, :hat, :story => :user)
|
||||
.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)
|
||||
.offset((@page - 1) * COMMENTS_PER_PAGE)
|
||||
|
||||
|
@ -346,7 +346,7 @@ class CommentsController < ApplicationController
|
|||
comments = Comment.accessible_to_user(@user)
|
||||
.where(:thread_id => thread_ids)
|
||||
.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)
|
||||
|
||||
comments_by_thread_id = comments.group_by(&:thread_id)
|
||||
|
|
|
@ -40,7 +40,7 @@ class StoriesController < ApplicationController
|
|||
return render :action => "edit"
|
||||
end
|
||||
|
||||
@story.is_expired = true
|
||||
@story.is_deleted = true
|
||||
@story.editor = @user
|
||||
|
||||
if @story.save(:validate => false)
|
||||
|
@ -229,7 +229,7 @@ class StoriesController < ApplicationController
|
|||
end
|
||||
|
||||
update_story_attributes
|
||||
@story.is_expired = false
|
||||
@story.is_deleted = false
|
||||
@story.editor = @user
|
||||
|
||||
if @story.save(:validate => false)
|
||||
|
@ -245,7 +245,7 @@ class StoriesController < ApplicationController
|
|||
return redirect_to "/"
|
||||
end
|
||||
|
||||
@story.is_expired = false
|
||||
@story.is_deleted = false
|
||||
@story.editor = @user
|
||||
update_story_attributes
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class Search
|
|||
|
||||
def with_stories_matching_tags(base, tag_scopes)
|
||||
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)
|
||||
base.where(story_id: story_ids_matching_tags)
|
||||
end
|
||||
|
@ -102,7 +102,7 @@ class Search
|
|||
|
||||
case self.what
|
||||
when "stories"
|
||||
base = Story.unmerged.where(:is_expired => false)
|
||||
base = Story.unmerged.where(is_deleted: false)
|
||||
if domain.present?
|
||||
base = with_stories_in_domain(base, domain)
|
||||
end
|
||||
|
|
|
@ -40,8 +40,8 @@ class Story < ApplicationRecord
|
|||
q = includes(:tags).unmerged
|
||||
user && user.is_moderator? ? q : q.not_deleted
|
||||
}
|
||||
scope :deleted, -> { where(is_expired: true) }
|
||||
scope :not_deleted, -> { where(is_expired: false) }
|
||||
scope :deleted, -> { where(is_deleted: true) }
|
||||
scope :not_deleted, -> { where(is_deleted: false) }
|
||||
scope :unmerged, -> { where(:merged_story_id => nil) }
|
||||
scope :positive_ranked, -> { where("score >= 0") }
|
||||
scope :low_scoring, ->(max = 5) { where("score < ?", max) }
|
||||
|
@ -269,7 +269,7 @@ class Story < ApplicationRecord
|
|||
Story
|
||||
.where(:url => urls)
|
||||
.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
|
||||
|
||||
# doesn't include deleted/moderated/merged stories
|
||||
|
@ -563,7 +563,7 @@ class Story < ApplicationRecord
|
|||
end
|
||||
|
||||
def is_gone?
|
||||
is_expired? || (self.user.is_banned? && score < 0)
|
||||
is_deleted? || (self.user.is_banned? && score < 0)
|
||||
end
|
||||
|
||||
def is_hidden_by_user?(user)
|
||||
|
@ -618,9 +618,9 @@ class Story < ApplicationRecord
|
|||
m.story_id = self.id
|
||||
|
||||
m.action = all_changes.map {|k, v|
|
||||
if k == "is_expired" && self.is_expired?
|
||||
if k == "is_deleted" && self.is_deleted?
|
||||
"deleted story"
|
||||
elsif k == "is_expired" && !self.is_expired?
|
||||
elsif k == "is_deleted" && !self.is_deleted?
|
||||
"undeleted story"
|
||||
elsif k == "merged_story_id"
|
||||
if v[1]
|
||||
|
|
|
@ -416,7 +416,7 @@ class User < ApplicationRecord
|
|||
self.email = "#{self.username}@lobsters.example" if \
|
||||
self.karma < 0 ||
|
||||
(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) ||
|
||||
FlaggedCommenters.new('90d').check_list_for(self)
|
||||
end
|
||||
|
@ -505,7 +505,7 @@ class User < ApplicationRecord
|
|||
Tag.active.joins(
|
||||
:stories
|
||||
).where(
|
||||
:stories => { :user_id => self.id, :is_expired => false }
|
||||
:stories => { :user_id => self.id, :is_deleted => false }
|
||||
).group(
|
||||
Tag.arel_table[:id]
|
||||
).order(
|
||||
|
|
|
@ -10,7 +10,7 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %>
|
|||
<%= story.score <= -5 ? "negative_5" : "" %>
|
||||
<%= story.is_hidden_by_cur_user ? "hidden" : "" %>
|
||||
<%= story.is_saved_by_cur_user ? "saved" : "" %>
|
||||
<%= story.is_expired? ? "expired" : "" %>">
|
||||
<%= story.is_deleted? ? "deleted" : "" %>">
|
||||
<div class="story_liner h-entry">
|
||||
<div class="voters">
|
||||
<% 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.
|
||||
|
||||
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|
|
||||
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.text "description", size: :medium
|
||||
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 "flags", default: 0, null: false, unsigned: true
|
||||
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 ["domain_id"], name: "index_stories_on_domain_id"
|
||||
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 ["score"], name: "index_stories_on_score"
|
||||
t.index ["short_id"], name: "unique_short_id", unique: true
|
||||
|
|
|
@ -60,7 +60,7 @@ class FakeDataGenerator
|
|||
title: title,
|
||||
tags_a: [tag.tag],
|
||||
description: Faker::Lorem.paragraphs(number: 1),
|
||||
is_expired: true,
|
||||
is_deleted: true,
|
||||
editor: user
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
).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
|
||||
Keystore.put(LAST_STORY_KEY, s.id)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ FactoryBot.define do
|
|||
tags_a { ["tag1", "tag2"] }
|
||||
|
||||
trait :deleted do
|
||||
is_expired { true }
|
||||
is_deleted { true }
|
||||
editor { user }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -112,7 +112,7 @@ RSpec.feature "Submitting Stories", type: :feature do
|
|||
end
|
||||
|
||||
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 {
|
||||
visit "/stories/new"
|
||||
fill_in "URL", with: s.url
|
||||
|
|
|
@ -177,7 +177,7 @@ describe 'stores', type: :request do
|
|||
|
||||
it 'does nothing to deleted comments' do
|
||||
expect {
|
||||
target.is_expired = true
|
||||
target.is_deleted = true
|
||||
target.editor = target.user
|
||||
target.save!
|
||||
|
||||
|
|
Loading…
Reference in New Issue