问答插件

This was occurring on all topics, not just QnA ones. We have a ‘Questions’ category when all topics are QnA, and also have the ‘question’ tag to make a topic QnA.

The behavior is slightly different now though, before the sort order they were given fixed them at the bottom of the list, now they are still out of order, but newer posts are below them.

1 个赞

Thanks @AJDurant.

One of our clients experienced this issue, so I was able to take a closer look at a dataset where it was occuring. I believe one issue here might be the when topics where a QA tag is removed are handled.

I’ve started a PR that addresses this issue, which @mbcahyono and I will work on

https://github.com/paviliondev/discourse-question-answer/pull/38

The way to fix the issue for a specific topic is:

./launcher enter app
rails c
topic = Topic.find(<topic_id>) 
topic.posts.each { |p| p.update_columns(sort_order: p.post_number) }

If anyone needs any more hands on help addressing this issue on their server please reach out to me privately and I can help you address it (no charge).

1 个赞

Sorry for not responding sooner. I’ve been traveling this week. I can confirm your code above is fixing the individual posts with issues.

I also confirmed that running the following command does NOT fix the problem

rake "posts:reorder_posts[1234]"

Is there a way to run this across all posts - basically loop over all posts?

And you’ve just run rake posts:reorder_posts by itself and it doesn’t work? Please try that again first.

If that doesn’t work you can run this

./launcher enter app
rails c
Post.update_all("sort_order = post_number")

We have figured out what the issue is. It was introduced back in August. We’ll push a fix for it shortly, with a test for the case.

https://github.com/paviliondev/discourse-question-answer/pull/38#issuecomment-739137531

2 个赞

I ran the above command and got the following error

root@REMOVE-web-only:/var/www/discourse# rake posts:reorder_posts
rake aborted!
PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "post_timings_unique"
DETAIL:  Key (topic_id, post_number, user_id)=(1567, 20, 3) already exists.
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-2.2.0/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-2.2.0/lib/patches/db/pg.rb:110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/mini_sql-0.3/lib/mini_sql/postgres/connection.rb:201:in `run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/mini_sql-0.3/lib/mini_sql/postgres/connection.rb:173:in `exec'
/var/www/discourse/lib/tasks/posts.rake:368:in `block (3 levels) in <main>'
/var/www/discourse/lib/tasks/posts.rake:351:in `each'
/var/www/discourse/lib/tasks/posts.rake:351:in `block (2 levels) in <main>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.3/lib/active_record/transactions.rb:212:in `transaction'
/var/www/discourse/lib/tasks/posts.rake:312:in `block in <main>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => posts:reorder_posts
(See full trace by running task with --trace)

I did not run the second command once I saw the duplicate key error thinking that might be a larger issue.

That looks like an issue with your db that’s independent of this, but blocking a fix here. I’ll pm you shortly and we can debug that seperately.

2 个赞

Thanks @angus that all seems to be working correctly now :smiley:

Running latest release and seeing the following errors.

Message (49 copies reported)

Job exception: uninitialized constant Jobs::QaUpdateTopicsPostOrder
Did you mean? Jobs::UpdateTopicPostOrder
Jobs::QAUpdateTopicsPostOrder

Backtrace

/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/inflector/methods.rb:284:in const_get' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/inflector/methods.rb:284:in block in constantize’
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/inflector/methods.rb:280:in each' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/inflector/methods.rb:280:in inject’
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/inflector/methods.rb:280:in constantize' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/core_ext/string/inflections.rb:68:in constantize’
/var/www/discourse/app/jobs/base.rb:288:in enqueue' /var/www/discourse/app/jobs/onceoff/onceoff.rb:40:in block in enqueue_all’
/var/www/discourse/app/jobs/onceoff/onceoff.rb:37:in each' /var/www/discourse/app/jobs/onceoff/onceoff.rb:37:in enqueue_all’

Sorry for the issue. Working on it, waiting to be merged:

https://github.com/paviliondev/discourse-question-answer/pull/39

1 个赞

Cool, I’m excited to see this merged and look forward to the fix. Happy Holidays.

What is the role of the “QnA one-to-many format.” setting that can be found in category settings?

1 个赞

It’s a deprecated feature, which we’ll be removing from the QnA Plugin in the near future. That feature now has it’s own dedicated plugin

2 个赞

How do you remove your vote? In options, there is a configuration of how much time you have to undo the vote, but I don’t see a way how to actually do that.

1 个赞

Are there any good examples of this plugin in use in the wild? I’d love to see it in action!

Select the yellow “Undo your upvote” text - see screenshot below.

I noticed a few feedback items:

  1. up icon to vote is not respecting dark theme (see screenshot)
  2. placement of my flair on comments on answers is off (see screenshot)
  3. styling of the info button is not bad but it doesn’t really match the rest of the page and takes up some horizontal space. Maybe a different approach, e.g. a small text link in the top right corner or next to the category and tag would work better? Screen Shot 2021-08-25 at 12.14.56 PM
  4. “Undo your upvote” link is not obviously a link
  5. qa trust level vote limits admin setting is deselected by default, but I still get an error “You cannot exceed the number of votes for your trust level” which doesn’t maek sense? Screen Shot 2021-08-25 at 12.18.37 PM
  1. Is there only a ‘Comment’ button on first post and the replies don’t show that button on bottom?

That’s OK by design or there is a bug in my theme?

  1. Upvoting is missaligned, I think that could be fixed by CSS (I will try to do it).

Thanks!

Can we recover the normal order of posts uninstalling the plugin?

I see that previous reported bug really messy our conversations :neutral_face:

Yes there seems to be a conflict between this plugin and the Solved Plugin, i.e. the “Solution” element in your screenshot. This plugin does not yet offiically support the Solved Plugin.

Yes, you just need to disable the plugin in a category in which its enabled and the posts will go back to their normal order.

1 个赞

感谢您的插件!有一个问题,如果移除插件,内容会怎样?很明显,投票和回复的特殊排序将消失,但“回复”和“评论”对于每个回复会怎样?它们会保留还是会消失?

我问的原因是,我们已经开始使用此插件来构建一个协作式用户指南。为每个回复添加评论非常方便。投票也很有前景,但如果它们带来意想不到的后果,而我们想摆脱它们呢?如果我们想移除投票就丢失指南那就太可惜了。

最坏的情况是,我想我们可以通过 CSS 移除投票界面,但保留插件。

1 个赞

好问题。

评论和答案只是以不同顺序显示的帖子。它们将被保留。

如果您想卸载插件,只需在类别设置中取消选中“将此类别中的所有主题设为问答”即可。这将把所有帖子恢复到其原始顺序。

例如,我刚刚在 try.thepavilion.io 上将问答类别恢复到其标准顺序(即按时间顺序排列(将在 24 小时后再次更改))。

https://try.thepavilion.io/t/whats-it-like-to-be-a-bat/22

2 个赞

好的,了解这一点很有鼓励性。我们会尝试使用该插件,如果投票未能达到预期目的,那么我们将有两种方法来移除它们:一种是轻量级的方法,通过 CSS;另一种是重量级的方法,禁用该插件。不会丢失任何内容。对 Discourse 核心组件的绝佳改编!

顺便说一句,如果您好奇的话,我们正在使用您的插件来创建一个产品的协作视频指南,人们可以链接到人们创建的关于该产品各个方面的视频。我们自定义了一些标签以使其正常工作。请参阅 Bitwig Video Guide - Bitwish (我们才刚开始,所以大部分是空的;此外,大多数子类别都被静音了,这就是为什么匿名用户看起来更空的原因)。

3 个赞