FIX: move total rows count & load more URL inside meta.
We're fetching "total rows count" from root attributes only if meta object not found. 2b78bd01ab/app/assets/javascripts/discourse/models/store.js (L236)
This commit is contained in:
parent
9c43963ff3
commit
2f9879a9a1
|
@ -81,8 +81,11 @@ class DirectoryItemsController < ApplicationController
|
|||
|
||||
last_updated_at = DirectoryItem.last_updated_at(period_type)
|
||||
render_json_dump(directory_items: serialize_data(result, DirectoryItemSerializer),
|
||||
meta: { last_updated_at: last_updated_at },
|
||||
total_rows_directory_items: result_count,
|
||||
load_more_directory_items: directory_items_path(more_params))
|
||||
meta: {
|
||||
last_updated_at: last_updated_at,
|
||||
total_rows_directory_items: result_count,
|
||||
load_more_directory_items: directory_items_path(more_params)
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,12 +44,12 @@ describe DirectoryItemsController do
|
|||
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items']).to be_present
|
||||
expect(json['total_rows_directory_items']).to be_present
|
||||
expect(json['load_more_directory_items']).to be_present
|
||||
expect(json['meta']['total_rows_directory_items']).to be_present
|
||||
expect(json['meta']['load_more_directory_items']).to be_present
|
||||
expect(json['meta']['last_updated_at']).to be_present
|
||||
|
||||
expect(json['directory_items'].length).to eq(4)
|
||||
expect(json['total_rows_directory_items']).to eq(4)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(4)
|
||||
end
|
||||
|
||||
it "fails when the directory is disabled" do
|
||||
|
@ -66,7 +66,7 @@ describe DirectoryItemsController do
|
|||
json = ::JSON.parse(response.body)
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(1)
|
||||
expect(json['total_rows_directory_items']).to eq(1)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(1)
|
||||
expect(json['directory_items'][0]['user']['username']).to eq('eviltrout')
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ describe DirectoryItemsController do
|
|||
json = ::JSON.parse(response.body)
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(1)
|
||||
expect(json['total_rows_directory_items']).to eq(1)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(1)
|
||||
expect(json['directory_items'][0]['user']['username']).to eq('stage_user')
|
||||
end
|
||||
|
||||
|
@ -88,7 +88,7 @@ describe DirectoryItemsController do
|
|||
json = ::JSON.parse(response.body)
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(2)
|
||||
expect(json['total_rows_directory_items']).to eq(2)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(2)
|
||||
expect(json['directory_items'][0]['user']['username']).to eq(walter_white.username) | eq(user.username)
|
||||
expect(json['directory_items'][1]['user']['username']).to eq(walter_white.username) | eq(user.username)
|
||||
end
|
||||
|
@ -100,7 +100,7 @@ describe DirectoryItemsController do
|
|||
json = ::JSON.parse(response.body)
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(2)
|
||||
expect(json['total_rows_directory_items']).to eq(2)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(2)
|
||||
expect(json['directory_items'][0]['user']['username']).to eq(evil_trout.username) | eq(stage_user.username)
|
||||
expect(json['directory_items'][1]['user']['username']).to eq(evil_trout.username) | eq(stage_user.username)
|
||||
end
|
||||
|
|
|
@ -602,8 +602,11 @@ export default {
|
|||
post_count: 146
|
||||
}
|
||||
],
|
||||
total_rows_directory_items: 12546,
|
||||
load_more_directory_items:
|
||||
"/directory_items?id=all&order=likes_received&page=1"
|
||||
meta: {
|
||||
last_updated_at: "2020-04-02T02:19:20.000Z",
|
||||
total_rows_directory_items: 12546,
|
||||
load_more_directory_items:
|
||||
"/directory_items?id=all&order=likes_received&page=1"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue