Commit Graph

103 Commits

Author SHA1 Message Date
Régis Hanol b31bc6e037
DEV: add `guardian` argument to `TopicsFilter` (#237)
As it's been added in discourse/discourse#31908
2025-03-24 11:34:48 +01:00
Natalie Tay 54d6607bf0
FIX: Care for nil counts when ordering (#205)
We allowed for https://meta.discourse.org/filter?q=order%3Avotes, but did not coalesce nils to zeroes. This resulted in nils being above higher voted topics.
2024-08-12 16:26:13 +08:00
Natalie Tay a1243b094f
FEATURE: Allow order:votes on /filter (#204)
Allow order:votes on /filter
2024-08-07 17:08:26 +08:00
Natalie Tay 3d3037729c
DEV: Scope topic voting tables to avoid confusion with post voting (#196)
Renaming discourse_voting to topic_voting since there are two forms of voting in Discourse - posts and topics.

This PR also moves a OnceOff into a post migration. The post migration will be executed, but should ideally be a no-op. This allows us to not have to maintain the OnceOff as it had to be modified before with a previous migration. I considered removing this file altogether, but I don't think there is anything negative from just converting it into a migration, and it might be useful in the unlikely scenario that a forum from the past has never ran the OnceOff before.
2024-07-17 20:26:40 +08:00
Natalie Tay fdb1f98a96
DEV: Autoload plugin files and namespace some jobs (#194) 2024-07-11 10:15:01 +08:00
Loïc Guitaut 9590a9823f
DEV: Update rubocop-discourse to version 3.8.0 (#190) 2024-05-28 11:52:45 +02:00
Renato Atilio 0ae9350771
FIX: merge votes regardless of voters' visibility (#187)
Ensures merging topics also merges votes regardless of the voters' visibility (when voting_show_who_voted site setting is false).
2024-05-02 10:40:51 -03:00
Loïc Guitaut fa6fe4abbf DEV: Fix new Rubocop offenses 2024-03-05 16:13:45 +01:00
Penar Musaraj 98115faada
FIX: Render votes RSS feed (#180) 2024-01-18 16:02:42 -05:00
Penar Musaraj be71ec457c
FIX: Rely on core for staff action logs (#176)
Previously, we were deleting the `enable_topic_voting` custom field param
and doing the staff logging in this plugin. This has a problem though, it
was being done in the model's create/destroy hooks and was missing the
acting user (so the logs would report the change as `system`).

This PR keeps the custom field param and relies on core to do the staff
action logging. This change also results in the custom field being set
in the DB when it is enabled even though we don't use it in the serializer.
2023-12-18 14:13:39 -05:00
Renato Atilio c1195c30f8
FIX: avoid reclaiming un-reclaimable votes (#175) 2023-12-11 12:07:35 -03:00
Martin Brennan db2581fc27
Metadata Update for plugin.rb (#173)
Co-authored-by: AlexDev <104522507+alexdevlaeminck@users.noreply.github.com>
2023-11-08 11:23:19 -08:00
Ted Johansson c7918e859e
DEV: Pass respect_plugin_enabled to add_to_serializer as keyword argument (#172)
Passing the respect_plugin_enabled argument to #add_to_serializer as a positional argument is deprecated. It is now expected to be a keyword argument. This PR adds the keyword.
2023-10-30 12:07:52 +08:00
Renato Atilio a5f13fa3ce
FEATURE: trigger a custom webhook on upvotes (#158)
* FEATURE: trigger a custom webhook on upvotes

* DEV: fix linting
2023-08-11 13:50:21 -03:00
David Taylor d9cab96642
DEV: Resolve add_to_serializer deprecations (#152)
26b7f8a63b
2023-04-24 15:08:12 +01:00
Natalie Tay 83877c5921
FIX: Don't remove custom fields when adding a new one to category serializer (#150) 2023-03-30 12:53:44 +08:00
Bianca Nenciu 5477ab631a
DEV: Update plugin to match latest guidelines (#146)
- Define extension modules
- Use different files instead of plugin.rb
- Make sure plugin is disabled according to the setting
2023-02-17 17:46:07 +02:00
Bianca Nenciu bf5ea9f2f5
DEV: Use plugin API to register event handlers (#144) 2023-02-14 16:54:59 +02:00
David Taylor 1284196081
DEV: Introduce syntax_tree for ruby formatting (#138) 2022-12-29 13:35:59 +01:00
Natalie Tay 1d81f8f3ed
DEV: Backfill tests before rename (#131) 2022-11-10 16:25:00 +08:00
Natalie Tay 9fab0ee3b3
DEV: Backfill tests before rename (#130) 2022-11-09 20:54:14 +08:00
Natalie Tay 6bbc982477
DEV: Plugin rename (#126)
Update metadata, Rename ruby module, Rename folders and filenames, Rename i18n keys
2022-11-02 13:42:06 +08:00
Vinoth Kannan 2de1fe5df1
FIX: add second order by column to preserve order while paging. (#109)
If the number of votes is the same and the second order-by column is not specified then Postgres makes no guarantee about what the ordering will be.
2022-03-04 10:03:39 +05:30
Roman Rizzi 5011df324c
FIX: Allow anons to view votes if the voting_show_votes_on_profile setting is enabled (#75) 2022-01-11 16:10:55 -03:00
Vinoth Kannan fc4d23174e
PERF: exclude vote fields in `topic-list-item` serializer for PMs. (#103)
We shouldn't add vote fields for personal messages since users can't vote there. If we include then it's creating an N+1 issue in the `private-messages-all` endpoint.
2021-09-16 18:56:02 +05:30
Penar Musaraj b8ee3c05ed
DEV: Remove some old committed (#100)
Reverts 18794557db
2021-07-22 14:48:09 -04:00
Dan Ungureanu 9e02c59be3
FIX: Delete votes associated with no user (#85)
Co-authored-by: Régis Hanol <regis@hanol.fr>
2021-04-07 14:43:07 +03:00
Alan Guo Xiang Tan ca82bab131
FIX: Search advanced order after changes in core. (#79)
See 4b3f65bb26
2021-02-05 09:55:33 +08:00
Bianca Nenciu dd21880cc4
FIX: Always serialize can_vote for first posts (#78)
Changing category settings would not always unhide the like button
because the model would not be updated on the client side until a full
page refresh.
2021-02-01 11:37:14 +02:00
Justin DiRose c82d5a6645
FIX: Stop trying to merge duplicate votes (#56)
Was able to reproduce a bug where votes were not properly moved when merging two topics together. We were only checking duplicate votes if either both votes were either active or archived, and not a mix of the two. As a result, there were cases where the plugin was trying to move votes that already existed on an open topic, causing the merge to partially fail with a duplicate index error.

What this commit does is as follows:

- Cleaned up the logic so it's more readable. Previously it was duplicative and difficult to read.
- We're now checking if a user has a vote on Topic A (active or archived) and Topic B (active or archived) that we're properly deleting the origin vote and keeping the destination vote instead of trying to merge in a duplicate. (This caused the original bug described above).
- Per the specs on meta, topic merges move all votes to the destination topic, and if this causes a user to go over the limit, they'll have to wait until enough votes are released.
- If the destination topic is closed, the votes will be archived; if the destination topic is open, those votes will be active. This is regardless of origin vote state.

Also, the Gemfile was missing a source declaration to allow installation of gems/dependencies, so I've added that.
2020-09-17 11:02:19 -05:00
Krzysztof Kotlarek 18794557db
FIX: backwards compatibility with stable discourse 2.5.0 (#53)
Few if statements to ensure plugin works with a stable discourse. Completely obsolete once 2.6.0 will become stable
2020-08-18 10:26:10 +10:00
Régis Hanol 8de0fa9ecf DEV: ensure compatibilty with stable 2020-08-17 16:21:16 +02:00
Régis Hanol 15949af1b9 FIX: suggested topics had their topic_ids set to a post_id
The fix is pretty simple

    result = result.select("*, ... AS current_user_voted")

become

    result = result.select("topics.*, ... AS current_user_voted")

I also merged all 3 'TopicQuery.results_filter_callbacks' into one and did
some slight refactoring on the 'add_to_serializer'.
2020-08-17 11:15:24 +02:00
Krzysztof Kotlarek 74c09d58b0 FIX: bump version to 0.5 2020-08-17 15:46:02 +10:00
Krzysztof Kotlarek 0f0e76f170
FIX: move data to separate tables (#52)
We are trying to avoid custom tables. Changes:
CategoryCustomField -> DiscourseVoting::CategorySetting # contains infromation if voting is enabled for category
UserCustomField -> DiscourseVoting::Vote # user's votes
TopicCustomField -> DiscourseVoting::VoteCounter # cache count for topics
2020-08-17 15:01:33 +10:00
Dan Ungureanu 639dce7a8b
FIX: Move archived votes when merging topics (#50) 2020-05-26 13:10:13 +03:00
Krzysztof Kotlarek c90fbe6fab FIX: include all reloadable parts of the plugin (#48)
Currently, if you got that plugin installed and change code in development in Discourse, you will see an error like:
`undefined method `can_vote?'`

A reason for that was incorrectly defined `reloadable_patch` block. That block defines everything which should be reloaded by ActiveSupport::Reloader if code is changed.

because that was not included in that block
```
class ::Category
  def self.can_vote?(category_id)
  end
end
```
method `can_vote?` was not anymore available.
2019-12-12 13:42:23 +11:00
Dan Ungureanu 2a3ca6f870
FEATURE: Let user know how many votes were moved. (#42)
Merging two votes with topics will edit the moderator post describing
the move operation, to include information about how many votes were
moved and why some votes were not (because user already voted for the
destination topic).
2019-10-08 12:35:20 +03:00
Mark VanLandingham 429dc1e532 FIX: user vote count is updated when topics are trashed/restored (#46)
* FIX: user vote count updates properly for trashed/recovered topics

* fixed weird tab sizing

* removed unused spec variable

* VoteRelease job queries deleted topics as well

* use Jobs.run_immediately!
2019-10-03 17:53:29 +10:00
Krzysztof Kotlarek 6bb3d188e5 FIX: Use top-level namespace for base classes (#45) 2019-10-02 14:30:27 +10:00
Sam Saffron d09feb47a0 FIX: keep plugin compatible with older discourse versions
Per: bd5fa173 in Discourse there is no longer need re-register serializers
in all descendants. This change was backported so this change to discourse
voting is safe.
2019-08-27 18:26:14 +10:00
Dan Ungureanu 7e6f27b198 FIX: Add can_vote attribute to all category serializers. (#43) 2019-08-22 14:50:20 +02:00
Joffrey JAFFEUX 020ed3cd6d FIX: wraps overrides in reloadable_patch 2019-08-22 14:31:03 +02:00
Sam Saffron 9b4f233b9d PERF: avoid N+1 on category load
`after_find` is a very risky callback cause it can impact how read perf
works. In this case it was loading a custom field on category which
triggered an N+1 on a fresh load of a site.

This amends it so we do the repair before save
2019-08-19 16:24:16 +10:00
David Taylor fd5c6d91f9 FIX: Reclaim votes when voting is disabled on a category 2019-07-18 16:53:03 +01:00
David Taylor 9e61d300b9 DEV: Define category_custom_field as boolean
This removes the need for casting to true/false strings on the client
2019-07-18 15:56:35 +01:00
Tomas Varaneckas 0cf0ed0edd FIX: ensure compatibility with older Discourse (#39)
Thank you!
2019-05-14 17:30:04 +08:00
Guo Xiang Tan 14b6603150 Add frozen string literal comment to files. 2019-05-13 11:11:19 +08:00
David Taylor fe264dc16c FIX: Do not transfer votes unless the entire topic is merged
We have logic to transfer votes if an entire topic is merged into another. However, we do not want this to trigger if only a few posts are moved.
2019-03-04 14:31:04 +00:00
Vinoth Kannan 3d53b86986 DEV: Use save_custom_fields method instead of save in topic object 2018-11-20 01:31:55 +05:30