FEATURE: order assigned list by reverse bump date

Previously this list was randomly ordered
This commit is contained in:
Sam Saffron 2019-11-01 15:35:01 +11:00
parent 68ff24739b
commit 0cea63029c
2 changed files with 11 additions and 6 deletions

View File

@ -90,7 +90,7 @@ module DiscourseAssign
.includes(:tags)
.includes(:user)
.joins("JOIN topic_custom_fields tcf ON topics.id = tcf.topic_id AND tcf.name = 'assigned_to_id' AND tcf.value IS NOT NULL")
.order('tcf.value')
.order('tcf.value, topics.bumped_at desc')
.offset(offset)
.limit(limit)

View File

@ -14,7 +14,7 @@ RSpec.describe DiscourseAssign::AssignController do
let(:above_min_version) do
min_version = 201_907_171_337_43
migrated_site_setting = DB.query_single(
DB.query_single(
"SELECT schema_migrations.version FROM schema_migrations WHERE schema_migrations.version = '#{min_version}'"
).first.present?
end
@ -162,8 +162,13 @@ RSpec.describe DiscourseAssign::AssignController do
before do
add_to_assign_allowed_group(user2)
freeze_time 1.hour.from_now
TopicAssigner.new(post1.topic, user).assign(user)
freeze_time 1.hour.from_now
TopicAssigner.new(post2.topic, user).assign(user2)
freeze_time 1.hour.from_now
TopicAssigner.new(post3.topic, user).assign(user)
sign_in(user)
@ -174,10 +179,10 @@ RSpec.describe DiscourseAssign::AssignController do
expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post2.topic_id, post1.topic_id, post3.topic_id])
get '/assign/assigned.json', params: { limit: 2 }
expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post2.topic_id, post1.topic_id])
expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post3.topic_id, post2.topic_id])
get '/assign/assigned.json', params: { offset: 2 }
expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post3.topic_id])
expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post1.topic_id])
end
end