FEATURE: post chunk size should not be configurable

If people need to configure post chunk size use a plugin
Core only supports out of the box settings, if changed can lead to
severe performance issues.
This commit is contained in:
Sam 2014-12-15 10:57:34 +11:00
parent 2eb47f8125
commit ae16186100
14 changed files with 20 additions and 31 deletions

View file

@ -739,8 +739,6 @@ en:
track_external_right_clicks: "Track external links that are right clicked (eg: open in new tab) disabled by default because it rewrites URLs"
topics_per_page: "How many topics are loaded by default on the topic list, and when scrolling down to load more topics"
slow_topics_per_page: "The amount of topics per page on slow devices such as Android"
posts_chunksize: "How many posts are loaded by default on a topic, and when scrolling down to load more posts"
posts_slow_chunksize: "Like `posts_chunksize` but for slow platforms (such as Android)"
site_contact_username: "All automated private messages will be from this user; if left blank the default System account will be used."
send_welcome_message: "Send all new users a welcome private message with a quick start guide."
suppress_reply_directly_below: "Don't show the expandable reply count on a post when there is only a single reply directly below this post."

View file

@ -668,7 +668,6 @@ es:
share_links: "Determina qué elementos aparecen en el cuadro de compartir y en qué orden"
track_external_right_clicks: "Hacer seguimiento de los enlaces externos en los que se ha hecho clic con el botón derecho (ej: abrir en nueva pestaña) desactivado por defecto porque reescribe URLs"
topics_per_page: "Cuántos temas se cargan por defecto en la lista de temas y cuando se hace scroll hacia abajo para cargar más temas"
posts_chunksize: "Cuantos posts son cargados por default en un tema, y cuando se desplaza hacia abajo para cargar mas posts."
site_contact_username: "Todos los mensajes privados automatizados serán de este usuario. Si es dejado en blanco, el la cuenta del Sistema por defecto será utilizada."
send_welcome_message: "Enviar a todos los nuevos usuarios un mensaje privado de bienvenida con una guía rápida para comenzar."
suppress_reply_directly_below: "No mostrar el contador de respuestas desplegable en un post si solo hay una única respuesta y está justamente debajo del post en cuestión."

View file

@ -668,7 +668,6 @@ fi:
share_links: "Mitkä painikkeet näytetään Jaa-valikossa ja missä järjestyksessä."
track_external_right_clicks: "Seuraa pois sivustolta vieviä linkkejä, jotka avataan hiiren oikealla näppäimellä (esim. avaa uudessa välilehdessä) oletuksena poistettu käytöstä, koska tämä kirjoittaa URL:n uudelleen"
topics_per_page: "Kuinka monta ketjua ladataan avattaessa ketjulista ja kerrallaan lisää vieritettäessä sivua alaspäin"
posts_chunksize: "Kuinka monta viestiä ladataa avattaessa viestiketju ja kerrallaan lisää vieritetäessä sivua alaspäin"
site_contact_username: "Kaikki automaattiset yksityisviestit lähetetään tämän käyttäjän nimissä; jos jätetään tyhjäksi oletuksena on System-käyttäjä."
send_welcome_message: "Lähetä kaikille uusille käyttäjille yksityinen tervetuliaisviesti, jossa on pikakäyttöopas."
suppress_reply_directly_below: "Älä näytä vastausten lukumäärää viestissä, jos ainoa vastaus on seuraavassa viestissä."

View file

@ -663,7 +663,6 @@ fr:
share_links: "Choix des éléments qui doivent apparaître dans la fenêtre de partage, et leur ordre."
track_external_right_clicks: "Suivi des clics sur les liens externes (ex: ouverture dans un nouvel onglet) désactivé par défaut car nécessite une ré-écriture de toutes les urls"
topics_per_page: "Combien de sujets seront chargés par défaut sur la liste des sujets et lors du défilement vers le bas pour charger des sujets supplémentaires"
posts_chunksize: "Combien de messages seront chargés par défaut sur un sujet, et quand défiler vers le bas pour charger des messages supplémentaires."
site_contact_username: "Tous les messages privés automatisés le seront depuis cet utilisateur; si non renseigné, le compte par défaut System sera utilisé."
send_welcome_message: "Envoyer à tous les nouveaux utilisateurs un message privé avec un guide de démarrage rapide."
suppress_reply_directly_below: "Ne pas afficher le panneau extensible des réponses d'un message quand la seule réponse est juste en dessous ce dernier."

View file

@ -658,7 +658,6 @@ he:
share_links: "החלט אילו פריטים יופיעו בתיבת השיתוף, ובאיזה סדר."
track_external_right_clicks: "Track external links that are right clicked (eg: open in new tab) disabled by default because it rewrites URLs"
topics_per_page: "כמה נושאים נטענים כברירת מחדל ברשימת הנושאים, ומתי גלילה למטה טוענת נושאים נוספים"
posts_chunksize: "כמה פרסומים לטעון כברירת מחדל תחת נושא מסוים, וכאשר יש גלילה למטה ייטענו פרסומים נוספים."
site_contact_username: "כל המסרים האישיים האוטומטיים יהיו ממשתמש זה; אם תשאירו ריק, יעשה שימוש בחשבון ברירת המחדל של המערכת."
send_welcome_message: "שלחו כל המשתמשים החדשים הודעת \"ברוכים הבאים\" פרטים עם הדרכה ראשונית כיצד להתחיל."
suppress_reply_directly_below: "אל תציגו את סך התגובות המצטבר בפרסום כאשר ישנה תגובה ישירה אחת לפרסום זה."

View file

@ -662,7 +662,6 @@ ru:
share_links: "Определите, какие элементы должны отображаться в окне 'Поделиться' и в какой последовательности."
track_external_right_clicks: "Отслеживать внешние ссылки, открытые правой кнопкой мыши (например: открыть в новой вкладке), по умолчанию отключено, так как это перезаписывает пути"
topics_per_page: "Сколько тем показывать сразу в списках тем, и подгружать за один раз при прокручивании списка вниз."
posts_chunksize: "Сколько сообщений показывать сразу на странице темы и подгружать за один раз при ее прокручивании вниз."
site_contact_username: "Все личные сообщения, отправляемые форумчанам автоматически, будут отправляться от имени этого пользователя. Если оставить пустым, то будет использован системный пользователь по-умолчанию - system."
send_welcome_message: "Отправлять новым зарегистрировавшимся пользователям приватное сообщение с короткой инструкцией по возможностям форума."
redirect_users_to_top_page: "Автоматически перенаправлять новых и давно отсутствующих пользователей к началу страницы."

View file

@ -667,7 +667,6 @@ sq:
share_links: "Determine which items appear on the share dialog, and in what order."
track_external_right_clicks: "Track external links that are right clicked (eg: open in new tab) disabled by default because it rewrites URLs"
topics_per_page: "How many topics are loaded by default on the topic list, and when scrolling down to load more topics"
posts_chunksize: "How many posts are loaded by default on a topic, and when scrolling down to load more posts"
site_contact_username: "All automated private messages will be from this user; if left blank the default System account will be used."
send_welcome_message: "Send all new users a welcome private message with a quick start guide."
suppress_reply_directly_below: "Don't show the expandable reply count on a post when there is only a single reply directly below this post."

View file

@ -622,7 +622,6 @@ tr_TR:
share_links: "Paylaşım penceresinde hangi maddelerin ne sırada gözükeceğini belirleyin."
track_external_right_clicks: "URL'leri tekrar yazdığı için, sağ tıklanan dış bağlantıların (ör: yeni bir sekmede aç) takibi varsayılan ayarlarda devre dışı bırakılmıştır."
topics_per_page: "Konu listesinde gözüken ve daha fazla konu görmek için sayfa aşağı kaydırıldığında yüklenen konu sayısı"
posts_chunksize: "Bir konuda gözüken ve daha fazla gönderi görmek için sayfa aşağı kaydırıldığında yüklenen gönderi sayısı"
site_contact_username: "Tüm otomatik özel mesajlar bu kullanıcıdan gönderilecek; boş bırakılırsa varsayılan Sistem hesabı kullanılır. "
send_welcome_message: "Tüm yeni kullanıcılara bir hoşgeldiniz özel mesajı ile beraber hızlı başlangıç kılavuzu gönderin."
suppress_reply_directly_below: "Bu gönderinin direk altında sadece tek bir cevap varsa, gönderideki açılabilir cevap sayısı bölümünü gösterme."

View file

@ -638,7 +638,6 @@ zh_CN:
share_links: "决定分享对话框中出现的按钮及显示顺序。"
track_external_right_clicks: "追踪外部链接的右键点击例如在浏览器新标签打开缺省是禁用的因为它会重写URL"
topics_per_page: "在主题列表页面,缺省载入多少个主题,以及滚动至什么时候载入更多主题"
posts_chunksize: "载入主题时默认载入多少帖子,以及向下滚动时载入多少帖子"
site_contact_username: "论坛给用户发送自动私信时使用的用户名;如果留空将使用默认的系统账户。"
send_welcome_message: "给所有用户发送快速开始指导的私信"
suppress_reply_directly_below: "当一个帖子只有一个回复时,不显示帖子回复数量。"

View file

@ -654,12 +654,6 @@ developer:
verbose_localization:
default: false
client: true
posts_chunksize:
default: 20
min: 1
posts_slow_chunksize:
default: 10
min: 1
embedding:
embeddable_host: ''

View file

@ -8,6 +8,14 @@ class TopicView
attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size
attr_accessor :draft, :draft_key, :draft_sequence, :user_custom_fields
def self.slow_chunk_size
10
end
def self.chunk_size
20
end
def initialize(topic_id, user=nil, options={})
@user = user
@guardian = Guardian.new(@user)
@ -20,7 +28,7 @@ class TopicView
@page = @page.to_i
@page = 1 if @page.zero?
@chunk_size = options[:slow_platform] ? SiteSetting.posts_slow_chunksize : SiteSetting.posts_chunksize
@chunk_size = options[:slow_platform] ? TopicView.slow_chunk_size : TopicView.chunk_size
@limit ||= @chunk_size
setup_filtered_posts

View file

@ -26,13 +26,13 @@ describe TopicView do
end
context "chunk_size" do
it "returns `posts_chunksize` by default" do
TopicView.new(topic.id, coding_horror).chunk_size.should == SiteSetting.posts_chunksize
it "returns `chunk_size` by default" do
TopicView.new(topic.id, coding_horror).chunk_size.should == TopicView.chunk_size
end
it "returns `posts_slow_chunksize` when slow_platform is true" do
it "returns `slow_chunk_size` when slow_platform is true" do
tv = TopicView.new(topic.id, coding_horror, slow_platform: true)
tv.chunk_size.should == SiteSetting.posts_slow_chunksize
tv.chunk_size.should == TopicView.slow_chunk_size
end
end
@ -128,8 +128,8 @@ describe TopicView do
end
it "generates a canonical correctly for paged results" do
SiteSetting.stubs(:posts_chunksize).returns(5)
TopicView.new(1234, user, post_number: 50).canonical_path.should eql("/1234?page=10")
TopicView.new(1234, user, post_number: 10 * TopicView.chunk_size )
.canonical_path.should eql("/1234?page=10")
end
end
@ -146,7 +146,7 @@ describe TopicView do
TopicView.any_instance.expects(:find_topic).with(1234).returns(topic)
TopicView.any_instance.stubs(:filter_posts)
TopicView.any_instance.stubs(:last_post).returns(p2)
SiteSetting.stubs(:posts_chunksize).returns(2)
TopicView.stubs(:chunk_size).returns(2)
end
it "should return the next page" do
@ -255,7 +255,7 @@ describe TopicView do
let!(:p3) { Fabricate(:post, topic: topic, user: first_poster)}
before do
SiteSetting.posts_chunksize = 3
TopicView.stubs(:chunk_size).returns(3)
# Update them to the sort order we're checking for
[p1, p2, p3, p4, p5, p6, p7].each_with_index do |p, idx|
@ -299,7 +299,7 @@ describe TopicView do
describe '#filter_posts_paged' do
before { SiteSetting.stubs(:posts_chunksize).returns(2) }
before { TopicView.stubs(:chunk_size).returns(2) }
it 'returns correct posts for all pages' do
topic_view.filter_posts_paged(1).should == [p1, p2]
@ -372,7 +372,7 @@ describe TopicView do
end
context "when 'posts per page' exceeds the number of posts" do
before { SiteSetting.stubs(:posts_chunksize).returns(100) }
before { TopicView.stubs(:chunk_size).returns(100) }
it 'returns all the posts' do
near_view = topic_view_near(p5)

View file

@ -656,19 +656,16 @@ describe TopicsController do
context 'filters' do
it 'grabs first page when no filter is provided' do
SiteSetting.stubs(:posts_chunksize).returns(20)
TopicView.any_instance.expects(:filter_posts_in_range).with(0, 19)
xhr :get, :show, topic_id: topic.id, slug: topic.slug
end
it 'grabs first page when first page is provided' do
SiteSetting.stubs(:posts_chunksize).returns(20)
TopicView.any_instance.expects(:filter_posts_in_range).with(0, 19)
xhr :get, :show, topic_id: topic.id, slug: topic.slug, page: 1
end
it 'grabs correct range when a page number is provided' do
SiteSetting.stubs(:posts_chunksize).returns(20)
TopicView.any_instance.expects(:filter_posts_in_range).with(20, 39)
xhr :get, :show, topic_id: topic.id, slug: topic.slug, page: 2
end

View file

@ -1,3 +1,3 @@
/*jshint maxlen:10000000 */
Discourse.SiteSettingsOriginal = {"title":"Discourse Meta","logo_url":"/assets/logo.png","logo_small_url":"/assets/logo-single.png","mobile_logo_url":"","favicon_url":"//meta.discourse.org/uploads/default/2499/79d53726406d87af.ico","allow_user_locale":false,"suggested_topics":7,"track_external_right_clicks":false,"ga_universal_tracking_code":"","ga_universal_domain_name":"auto","ga_tracking_code":"UA-33736483-2","ga_domain_name":"","top_menu":"latest|new|unread|starred|categories|top","post_menu":"like|share|flag|edit|bookmark|delete|admin|reply","post_menu_hidden_items":"edit|delete|admin","share_links":"twitter|facebook|google+|email","category_colors":"BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890","enable_mobile_theme":true,"relative_date_duration":14,"category_featured_topics":4,"fixed_category_positions":false,"show_subcategory_list":false,"posts_chunksize":20,"enable_badges":true,"invite_only":false,"login_required":false,"must_approve_users":false,"enable_local_logins":true,"allow_new_registrations":true,"enable_google_logins":true,"enable_google_oauth2_logins":false,"enable_yahoo_logins":true,"enable_twitter_logins":true,"enable_facebook_logins":true,"enable_github_logins":true,"enable_sso":false,"min_username_length":3,"max_username_length":20,"min_password_length":8,"enable_names":true,"invites_shown":30,"delete_user_max_post_age":60,"delete_all_posts_max":15,"min_post_length":20,"min_private_message_post_length":10,"max_post_length":32000,"min_topic_title_length":15,"max_topic_title_length":255,"min_private_message_title_length":2,"allow_uncategorized_topics":true,"min_title_similar_length":10,"min_body_similar_length":15,"edit_history_visible_to_public":true,"delete_removed_posts_after":24,"traditional_markdown_linebreaks":false,"suppress_reply_directly_below":true,"suppress_reply_directly_above":true,"newuser_max_images":0,"newuser_max_attachments":0,"display_name_on_posts":true,"short_progress_text_threshold":10000,"default_code_lang":"lang-auto","autohighlight_all_code":false,"email_in":false,"max_image_size_kb":3072,"max_attachment_size_kb":1024,"authorized_extensions":".jpg|.jpeg|.png|.gif|.svg|.txt|.ico|.yml","max_image_width":690,"max_image_height":500,"allow_profile_backgrounds":true,"allow_uploaded_avatars":true,"allow_animated_avatars":false,"tl1_requires_read_posts":30,"enable_long_polling":true,"polling_interval":3000,"anon_polling_interval":30000,"flush_timings_secs":5,"tos_url":"","privacy_policy_url":"","tos_accept_required":false,"faq_url":"","allow_restore":false,"maximum_backups":7,"version_checks":true,"suppress_uncategorized_badge":true,"min_search_term_length":3,"topic_views_heat_low":1000,"topic_views_heat_medium":2000,"topic_views_heat_high":5000,"global_notice":"","show_create_topics_notice":true,"available_locales":"cs|da|de|en|es|fr|he|id|it|ja|ko|nb_NO|nl|pl_PL|pt|pt_BR|ru|sv|uk|zh_CN|zh_TW"};
Discourse.SiteSettingsOriginal = {"title":"Discourse Meta","logo_url":"/assets/logo.png","logo_small_url":"/assets/logo-single.png","mobile_logo_url":"","favicon_url":"//meta.discourse.org/uploads/default/2499/79d53726406d87af.ico","allow_user_locale":false,"suggested_topics":7,"track_external_right_clicks":false,"ga_universal_tracking_code":"","ga_universal_domain_name":"auto","ga_tracking_code":"UA-33736483-2","ga_domain_name":"","top_menu":"latest|new|unread|starred|categories|top","post_menu":"like|share|flag|edit|bookmark|delete|admin|reply","post_menu_hidden_items":"edit|delete|admin","share_links":"twitter|facebook|google+|email","category_colors":"BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890","enable_mobile_theme":true,"relative_date_duration":14,"category_featured_topics":4,"fixed_category_positions":false,"show_subcategory_list":false,"enable_badges":true,"invite_only":false,"login_required":false,"must_approve_users":false,"enable_local_logins":true,"allow_new_registrations":true,"enable_google_logins":true,"enable_google_oauth2_logins":false,"enable_yahoo_logins":true,"enable_twitter_logins":true,"enable_facebook_logins":true,"enable_github_logins":true,"enable_sso":false,"min_username_length":3,"max_username_length":20,"min_password_length":8,"enable_names":true,"invites_shown":30,"delete_user_max_post_age":60,"delete_all_posts_max":15,"min_post_length":20,"min_private_message_post_length":10,"max_post_length":32000,"min_topic_title_length":15,"max_topic_title_length":255,"min_private_message_title_length":2,"allow_uncategorized_topics":true,"min_title_similar_length":10,"min_body_similar_length":15,"edit_history_visible_to_public":true,"delete_removed_posts_after":24,"traditional_markdown_linebreaks":false,"suppress_reply_directly_below":true,"suppress_reply_directly_above":true,"newuser_max_images":0,"newuser_max_attachments":0,"display_name_on_posts":true,"short_progress_text_threshold":10000,"default_code_lang":"lang-auto","autohighlight_all_code":false,"email_in":false,"max_image_size_kb":3072,"max_attachment_size_kb":1024,"authorized_extensions":".jpg|.jpeg|.png|.gif|.svg|.txt|.ico|.yml","max_image_width":690,"max_image_height":500,"allow_profile_backgrounds":true,"allow_uploaded_avatars":true,"allow_animated_avatars":false,"tl1_requires_read_posts":30,"enable_long_polling":true,"polling_interval":3000,"anon_polling_interval":30000,"flush_timings_secs":5,"tos_url":"","privacy_policy_url":"","tos_accept_required":false,"faq_url":"","allow_restore":false,"maximum_backups":7,"version_checks":true,"suppress_uncategorized_badge":true,"min_search_term_length":3,"topic_views_heat_low":1000,"topic_views_heat_medium":2000,"topic_views_heat_high":5000,"global_notice":"","show_create_topics_notice":true,"available_locales":"cs|da|de|en|es|fr|he|id|it|ja|ko|nb_NO|nl|pl_PL|pt|pt_BR|ru|sv|uk|zh_CN|zh_TW"};
Discourse.SiteSettings = jQuery.extend(true, {}, Discourse.SiteSettingsOriginal);