Commit Graph

41 Commits

Author SHA1 Message Date
Bianca Nenciu 20a17f248c
FIX: Make sure featured category topics are unique (#18343)
In the past, CategoryFeaturedTopic.feature_topics raised an exception
sometimes because it tried to create multiple CategoryFeaturedTopic
records for the same topic.

This code should not raise any exceptions as long as the list of new
topic IDs is unique because all previous records are deleted first,
then recreated and everything happens inside a transaction. The previous
rescue block was dead code anyway because it tried to catch
PG::UniqueViolation instead of ActiveRecord::RecordNotUnique. This
commit includes a fix to ensure that the topic IDs are unique.
2022-09-27 14:01:22 +03:00
Kane York 52278ce6fd
FIX: Use Discourse.system_user when we need a placeholder admin (#9781) 2020-06-24 15:51:30 +10:00
Sam Saffron d0d5a138c3
DEV: stop freezing frozen strings
We have the `# frozen_string_literal: true` comment on all our
files. This means all string literals are frozen. There is no need
to call #freeze on any literals.

For files with `# frozen_string_literal: true`

```
puts %w{a b}[0].frozen?
=> true

puts "hi".frozen?
=> true

puts "a #{1} b".frozen?
=> true

puts ("a " + "b").frozen?
=> false

puts (-("a " + "b")).frozen?
=> true
```

For more details see: https://samsaffron.com/archive/2018/02/16/reducing-string-duplication-in-ruby
2020-04-30 16:48:53 +10:00
Joffrey JAFFEUX 0d3d2c43a0
DEV: s/\$redis/Discourse\.redis (#8431)
This commit also adds a rubocop rule to prevent global variables.
2019-12-03 10:05:53 +01:00
Vinoth Kannan 3bb7ad4be1
FEATURE: remove support for 'suppress_from_latest' category setting. (#8308) 2019-11-18 12:28:35 +05:30
Bianca Nenciu 8e133de831
FIX: Ensure suppressed categories do not produce any featured topics. (#7863) 2019-07-15 17:32:03 +03:00
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00
Sam 7aa56fc9d9 refinement and test for batch mode on feature_topics 2017-12-20 13:58:05 +11:00
Neil Lalonde f5a3be750c PERF: add option to limit how many categories are processed in one call to CategoryFeaturedTopic.feature_topics (#5446) 2017-12-20 13:42:29 +11:00
Guo Xiang Tan 77d4c4d8dc Fix all the errors to get our tests green on Rails 5.1. 2017-09-25 13:48:58 +08:00
Sam c2a6616035 Correct erratic spec failure 2017-08-17 15:26:31 -04:00
Guo Xiang Tan 5012d46cbd Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
Neil Lalonde 262016604d FEATURE: each category can control how many topics to show on categories page 2017-03-01 15:12:57 -05:00
Sam Saffron 9893953f62 PERF: no need to nest a transaction when featuring topics
adding featured topics is already in a transaction, no need to nest
2016-07-16 15:36:40 +10:00
Sam Saffron 4cef1c1750 PERF: stop featuring users on categories
(this feature has long been removed, no need to run expensive queries
every 15 minutes)
2016-07-16 15:33:57 +10:00
Robin Ward 2cc6efba8c
FIX: Featuring topics wasn't happy with concurrency. 2016-05-03 14:24:50 -04:00
Neil Lalonde 2ae032c9b0 FIX: categories page would sometimes show no topics, even if there are some visible topics to show 2015-09-21 18:13:14 -04:00
Sam 8370b26cba PERF: optimise pinned handling on home page
Old query used to scan the full topics table, on home page

Instead we now perform 2 queries, one for pinned and one for unpinned and merge
results in a 10x improvement on a 1 million topic DB
2015-02-23 16:51:21 +11:00
Régis Hanol 8f45091ba5 FIX: don't try to feature a topic more than once per category 2014-09-10 16:18:28 +02:00
Sam 414c6d191f FIX: remove nullable dates post upgrade to Rails 4 2014-08-27 15:19:25 +10:00
Akshay 9d11ccc42e removed usless access modifiers specified in models 2014-08-19 07:28:21 +05:30
Sam b1d5f4440b Annotate models 2014-05-28 12:30:57 +10:00
Sam 862a6696c0 Correct annotations
allow longer usernames (up to 60)
2014-04-15 15:53:48 +10:00
Régis Hanol 6373de550f update annotations 2014-04-08 17:35:44 +02:00
Robin Ward 350eb82223 Don't include category definitions on Categories page 2014-02-07 17:01:31 -05:00
Sam 43ceaae7ba PERF: optimise featuring of topics and users
Previously this would delete all features and recreate, causing
uneeded network traffic and db pain
2014-01-30 10:32:20 +11:00
Régis Hanol 567d2bd23c add top page 2013-12-24 00:50:36 +01:00
Sam 5caa7a0e4d improve performance of periodical update job, decrease frequency and shift it by a few minutes 2013-09-30 16:59:16 +10:00
Einar Jonsson e06356ebbe Extracted a fake_admin method 2013-08-30 17:39:31 +00:00
Régis Hanol 9a7df140b7 updated model annotations 2013-08-13 22:09:27 +02:00
Neil Lalonde f39f44ddbf Categories page should not show invisible topics 2013-06-20 16:07:53 -04:00
Régis Hanol 454636abf1 annotate models 2013-06-17 02:49:34 +02:00
Neil Lalonde f62c421c91 Render category descriptions differently on the categories page 2013-06-14 11:18:44 -04:00
Sam 9a57aaaaa9 fix encoding for category excerpt
fix missing secure category topics in categories page
2013-06-05 11:22:47 +10:00
Robin Ward 560fb15d8a Include pinned topics in category list.
- removes an (n+1) query for user data
- supports the preload store for the data to avoid a second request
- fix a bug where uncategorizes was reporting (0, 0, 0) for topics by week, month, year
2013-05-28 15:36:16 -04:00
Sam ca2dee52db moved comments to the bottom, they are way less intrusive there 2013-05-24 12:48:32 +10:00
Sam 2cd95bc649 lets try out annotations 2013-05-24 12:35:14 +10:00
Robin Ward 459c7e3d59 Include pinned on Categories page 2013-04-03 11:45:53 -04:00
Gosha Arinich 6e5399d544 minor cleanup, using AR querying DSL over raw SQL in some places 2013-02-28 21:54:12 +03:00
Jakub Arnold 61654ab8f0 Fix all the trailing whitespace 2013-02-07 16:45:24 +01:00
Robin Ward 21b5628528 Initial release of Discourse 2013-02-05 14:16:51 -05:00