FEATURE: order assigned list by reverse bump date
Previously this list was randomly ordered
This commit is contained in:
parent
68ff24739b
commit
0cea63029c
|
@ -90,7 +90,7 @@ module DiscourseAssign
|
||||||
.includes(:tags)
|
.includes(:tags)
|
||||||
.includes(:user)
|
.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")
|
.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)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
|
|
||||||
let(:above_min_version) do
|
let(:above_min_version) do
|
||||||
min_version = 201_907_171_337_43
|
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}'"
|
"SELECT schema_migrations.version FROM schema_migrations WHERE schema_migrations.version = '#{min_version}'"
|
||||||
).first.present?
|
).first.present?
|
||||||
end
|
end
|
||||||
|
@ -162,8 +162,13 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
before do
|
before do
|
||||||
add_to_assign_allowed_group(user2)
|
add_to_assign_allowed_group(user2)
|
||||||
|
|
||||||
|
freeze_time 1.hour.from_now
|
||||||
TopicAssigner.new(post1.topic, user).assign(user)
|
TopicAssigner.new(post1.topic, user).assign(user)
|
||||||
|
|
||||||
|
freeze_time 1.hour.from_now
|
||||||
TopicAssigner.new(post2.topic, user).assign(user2)
|
TopicAssigner.new(post2.topic, user).assign(user2)
|
||||||
|
|
||||||
|
freeze_time 1.hour.from_now
|
||||||
TopicAssigner.new(post3.topic, user).assign(user)
|
TopicAssigner.new(post3.topic, user).assign(user)
|
||||||
|
|
||||||
sign_in(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])
|
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 }
|
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 }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue