Commit Graph

20 Commits

Author SHA1 Message Date
Nat 81bd69030b
Rename symbols 2022-11-10 17:42:52 +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
Martin Brennan 1775d948b4
DEV: Fix flaky spec (#94)
The issue was that when we were moving the post using posts[1,2]
the ordering was not always consistent, so sometimes we moved post
number 1 for the topic and sometimes post number 2.

If post number 1 was moved, the PostMover just creates a copy of it
in the destination topic, as the OP of the topic cannot be moved.

If post number 2 was moved, then PostMover _actually_ moves it to
the destination topic, and thus leaves only one post behind in
the original topic, which causes the original topic to be closed
and makes the spec fail.

This change ensures that post number 1 is the one we are moving
in the test, making sure the order is constant.
2021-06-07 13:32:47 +08:00
Martin Brennan 220bedaef8
DEV: Disable flaky spec 2021-06-07 13:42:00 +10:00
David Taylor b3122ff72f
DEV: Cleanup DiscourseEvent handler after spec (#67)
See https://github.com/discourse/discourse/pull/11205
2020-11-11 19:13:02 +00: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 e2c2f51799 FIX: dont error when topic without category 2020-08-17 16:18:16 +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
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
David Taylor fd5c6d91f9 FIX: Reclaim votes when voting is disabled on a category 2019-07-18 16:53:03 +01: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
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 33e67abe7b add spec 2018-09-06 17:02:08 +03:00
OsamaSayegh 5bcdfaa47b FIX: release/relcaim votes when topic is closed, clear duplicate and null votes 2018-09-06 16:27:08 +03:00
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
Dan Ungureanu d176ba458e FIX: Move votes to destination topic when two topics are merged. (#30) 2018-07-31 12:29:57 +10:00