Skip to content
Snippets Groups Projects
Commit 850ef3bd authored by ArtOfCode-'s avatar ArtOfCode-
Browse files

Use DateTime

parent 6cc65141
No related branches found
No related tags found
No related merge requests found
...@@ -197,7 +197,7 @@ class AdvertisementController < ApplicationController ...@@ -197,7 +197,7 @@ class AdvertisementController < ApplicationController
if category.nil? if category.nil?
category = Category.where(use_for_advertisement: true) category = Category.where(use_for_advertisement: true)
end end
Post.undeleted.where(last_activity: (Rails.env.development? ? 365 : 7).days.ago..Time.zone.now) Post.undeleted.where(last_activity: (Rails.env.development? ? 365 : 7).days.ago..DateTime.now)
.where(post_type_id: Question.post_type_id) .where(post_type_id: Question.post_type_id)
.where(category: category) .where(category: category)
.where('score > ?', SiteSetting['HotPostsScoreThreshold']) .where('score > ?', SiteSetting['HotPostsScoreThreshold'])
......
...@@ -115,7 +115,7 @@ class ApplicationController < ActionController::Base ...@@ -115,7 +115,7 @@ class ApplicationController < ActionController::Base
end end
def check_edits_limit!(post) def check_edits_limit!(post)
recent_edits = SuggestedEdit.where(created_at: 24.hours.ago..Time.zone.now, user: current_user) \ recent_edits = SuggestedEdit.where(created_at: 24.hours.ago..DateTime.now, user: current_user) \
.where('active = TRUE OR accepted = FALSE').count .where('active = TRUE OR accepted = FALSE').count
max_edits = SiteSetting[if current_user.privilege?('unrestricted') max_edits = SiteSetting[if current_user.privilege?('unrestricted')
...@@ -232,7 +232,7 @@ class ApplicationController < ActionController::Base ...@@ -232,7 +232,7 @@ class ApplicationController < ActionController::Base
end end
@hot_questions = Rails.cache.fetch("#{RequestContext.community_id}/hot_questions", expires_in: 4.hours) do @hot_questions = Rails.cache.fetch("#{RequestContext.community_id}/hot_questions", expires_in: 4.hours) do
Rack::MiniProfiler.step 'hot_questions: cache miss' do Rack::MiniProfiler.step 'hot_questions: cache miss' do
Post.undeleted.where(last_activity: (Rails.env.development? ? 365 : 7).days.ago..Time.zone.now) Post.undeleted.where(last_activity: (Rails.env.development? ? 365 : 7).days.ago..DateTime.now)
.where(post_type_id: [Question.post_type_id, Article.post_type_id]) .where(post_type_id: [Question.post_type_id, Article.post_type_id])
.joins(:category).where(categories: { use_for_hot_posts: true }) .joins(:category).where(categories: { use_for_hot_posts: true })
.where('score >= ?', SiteSetting['HotPostsScoreThreshold']) .where('score >= ?', SiteSetting['HotPostsScoreThreshold'])
......
...@@ -15,7 +15,7 @@ class CommentsController < ApplicationController ...@@ -15,7 +15,7 @@ class CommentsController < ApplicationController
@comment = Comment.new comment_params.merge(user: current_user) @comment = Comment.new comment_params.merge(user: current_user)
recent_comments = Comment.where(created_at: 24.hours.ago..Time.zone.now, user: current_user).where \ recent_comments = Comment.where(created_at: 24.hours.ago..DateTime.now, user: current_user).where \
.not(post: Post.includes(:parent).where(parents_posts: { user_id: current_user.id })) \ .not(post: Post.includes(:parent).where(parents_posts: { user_id: current_user.id })) \
.where.not(post: Post.where(user_id: current_user.id)).count .where.not(post: Post.where(user_id: current_user.id)).count
max_comments_per_day = SiteSetting[current_user.privilege?('unrestricted') ? 'RL_Comments' : 'RL_NewUserComments'] max_comments_per_day = SiteSetting[current_user.privilege?('unrestricted') ? 'RL_Comments' : 'RL_NewUserComments']
......
...@@ -9,7 +9,7 @@ class FlagsController < ApplicationController ...@@ -9,7 +9,7 @@ class FlagsController < ApplicationController
PostFlagType.find params[:flag_type] PostFlagType.find params[:flag_type]
end end
recent_flags = Flag.where(created_at: 24.hours.ago..Time.zone.now, user: current_user).count recent_flags = Flag.where(created_at: 24.hours.ago..DateTime.now, user: current_user).count
max_flags_per_day = SiteSetting[current_user.privilege?('unrestricted') ? 'RL_Flags' : 'RL_NewUserFlags'] max_flags_per_day = SiteSetting[current_user.privilege?('unrestricted') ? 'RL_Flags' : 'RL_NewUserFlags']
if recent_flags >= max_flags_per_day if recent_flags >= max_flags_per_day
......
...@@ -68,7 +68,7 @@ class PostsController < ApplicationController ...@@ -68,7 +68,7 @@ class PostsController < ApplicationController
level_name = @post_type.is_top_level? ? 'TopLevel' : 'SecondLevel' level_name = @post_type.is_top_level? ? 'TopLevel' : 'SecondLevel'
level_type_ids = @post_type.is_top_level? ? top_level_post_types : second_level_post_types level_type_ids = @post_type.is_top_level? ? top_level_post_types : second_level_post_types
recent_level_posts = Post.where(created_at: 24.hours.ago..Time.zone.now, user: current_user) recent_level_posts = Post.where(created_at: 24.hours.ago..DateTime.now, user: current_user)
.where(post_type_id: level_type_ids).count .where(post_type_id: level_type_ids).count
setting_name = current_user.privilege?('unrestricted') ? "RL_#{level_name}Posts" : "RL_NewUser#{level_name}Posts" setting_name = current_user.privilege?('unrestricted') ? "RL_#{level_name}Posts" : "RL_NewUser#{level_name}Posts"
max_posts = SiteSetting[setting_name] max_posts = SiteSetting[setting_name]
...@@ -230,7 +230,7 @@ class PostsController < ApplicationController ...@@ -230,7 +230,7 @@ class PostsController < ApplicationController
return return
end end
if @post.update(closed: false, closed_by: current_user, closed_at: Time.zone.now, if @post.update(closed: false, closed_by: current_user, closed_at: DateTime.now,
last_activity: DateTime.now, last_activity_by: current_user, last_activity: DateTime.now, last_activity_by: current_user,
close_reason: nil, duplicate_post: nil) close_reason: nil, duplicate_post: nil)
PostHistory.question_reopened(@post, current_user) PostHistory.question_reopened(@post, current_user)
......
...@@ -15,7 +15,7 @@ class SuspiciousVotesController < ApplicationController ...@@ -15,7 +15,7 @@ class SuspiciousVotesController < ApplicationController
def investigated def investigated
@sv = SuspiciousVote.find params[:id] @sv = SuspiciousVote.find params[:id]
@sv.was_investigated = true @sv.was_investigated = true
@sv.investigated_at = Time.zone.now @sv.investigated_at = DateTime.now
@sv.investigated_by = current_user.id @sv.investigated_by = current_user.id
if @sv.save if @sv.save
render json: { status: 'success' } render json: { status: 'success' }
......
...@@ -10,7 +10,7 @@ class VotesController < ApplicationController ...@@ -10,7 +10,7 @@ class VotesController < ApplicationController
render(json: { status: 'failed', message: 'You may not vote on your own posts.' }, status: :forbidden) && return render(json: { status: 'failed', message: 'You may not vote on your own posts.' }, status: :forbidden) && return
end end
recent_votes = Vote.where(created_at: 24.hours.ago..Time.zone.now, user: current_user) \ recent_votes = Vote.where(created_at: 24.hours.ago..DateTime.now, user: current_user) \
.where.not(post: Post.includes(:parent).where(parents_posts: { user_id: current_user.id })).count .where.not(post: Post.includes(:parent).where(parents_posts: { user_id: current_user.id })).count
max_votes_per_day = SiteSetting[current_user.privilege?('unrestricted') ? 'RL_Votes' : 'RL_NewUserVotes'] max_votes_per_day = SiteSetting[current_user.privilege?('unrestricted') ? 'RL_Votes' : 'RL_NewUserVotes']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment