Commit Graph

85 Commits

Author SHA1 Message Date
Nat 81bd69030b
Rename symbols 2022-11-10 17:42:52 +08: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
Joshua Rosenfeld 7235aa12a4
forgot a letter in the url 2018-10-12 17:14:56 -04:00
Joshua Rosenfeld 7beb0d9e2c
Update url 2018-10-12 15:47:32 -04:00
Sam 25c5f2d5ea FIX: improve reconciliation of votes job
Also cleans up all custom field usage and tests

Adds a few missing tests
2018-09-21 11:49:41 +10:00
OsamaSayegh 5bcdfaa47b FIX: release/relcaim votes when topic is closed, clear duplicate and null votes 2018-09-06 16:27:08 +03:00
Arpit Jalan 45c4c3b583 FIX: update vote counts only if voters are visible 2018-08-29 22:19:20 +05:30
Osama Sayegh 070781149a FIX: release/reclaim votes on moving topics to different category (#34)
* FIX: release/reclaim votes on moving topics to different category

* test jobs

* don't enqueue job if there are no votes
2018-08-15 17:53:54 +10:00
Jeff Wong 85f39aff81 FIX: only count votes when we have an array of votes 2018-08-09 12:02:04 -07:00
Yaw Anokwa a6b0e9753a FIX: Do not count nil or blank values as votes (#33) 2018-08-08 13:16:47 +10:00
Jeff Wong 67c847fc5a FIX: do not count nil values as votes 2018-08-06 11:27:10 -07:00
Dan Ungureanu d176ba458e FIX: Move votes to destination topic when two topics are merged. (#30) 2018-07-31 12:29:57 +10:00
Sam 34485a8dc8 FIX: workaround vote count being an array 2018-05-18 12:07:44 +10:00
Michael Brown 8e7f775f1b FIX: USERNAME_ROUTE_FORMAT is now RouteFormat.username 2017-12-21 17:32:31 -05:00
Guo Xiang Tan 604a03639b UX: Target area for vote button too small on mobile. 2017-06-14 10:53:44 +09:00
Sam b96dd07033 FEATURE: add alert when less than 10 votes left 2017-03-08 12:44:30 -05:00
Sam 5112e2bc18 Remove voting for category description 2017-03-06 17:07:03 -05:00
Sam 006dcb85b0 Rename feature voting to voting 2017-03-06 15:38:26 -05:00
Sam bddea3ce7c FEATURE: add votes tab for on "votable" categories 2017-03-06 15:00:56 -05:00
Sam 619737d209 FEATURE: remove "liking" on OP for topics with voting 2017-03-03 16:58:07 -05:00