log(graphql): log deprecated order argument usage
This commit is contained in:
parent
a26c82cde7
commit
99e22a8cbe
3 changed files with 18 additions and 1 deletions
|
@ -40,6 +40,7 @@ class API::V2::BaseController < ApplicationController
|
||||||
if @api_token.present?
|
if @api_token.present?
|
||||||
@api_token.touch(:last_v2_authenticated_at)
|
@api_token.touch(:last_v2_authenticated_at)
|
||||||
@current_user = @api_token.administrateur.user
|
@current_user = @api_token.administrateur.user
|
||||||
|
Current.user = @current_user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,9 +79,16 @@ module Connections
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_nodes_deprecated_order(limit, inverted)
|
def load_nodes_deprecated_order(limit, inverted)
|
||||||
|
payload = {
|
||||||
|
message: "CursorConnection: using deprecated order [#{Current.user.email}]",
|
||||||
|
user_id: Current.user.id
|
||||||
|
}
|
||||||
|
logger = Lograge.logger || Rails.logger
|
||||||
|
logger.info payload.to_json
|
||||||
|
|
||||||
expected_size = limit - 1
|
expected_size = limit - 1
|
||||||
|
|
||||||
if @deprecated_order == :desc && before.nil?
|
if before.nil?
|
||||||
inverted = !inverted
|
inverted = !inverted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,9 @@ describe API::V2::GraphqlController do
|
||||||
let(:end_cursor) { cursor_for(dossier2, order_column) }
|
let(:end_cursor) { cursor_for(dossier2, order_column) }
|
||||||
|
|
||||||
it {
|
it {
|
||||||
|
allow(Rails.logger).to receive(:info)
|
||||||
|
expect(Rails.logger).to receive(:info).with("{\"message\":\"CursorConnection: using deprecated order [#{admin.email}]\",\"user_id\":#{admin.user.id}}")
|
||||||
|
|
||||||
expect(gql_errors).to be_nil
|
expect(gql_errors).to be_nil
|
||||||
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
|
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
|
||||||
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_truthy
|
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_truthy
|
||||||
|
@ -216,6 +219,9 @@ describe API::V2::GraphqlController do
|
||||||
let(:end_cursor) { cursor_for(dossier, order_column) }
|
let(:end_cursor) { cursor_for(dossier, order_column) }
|
||||||
|
|
||||||
it {
|
it {
|
||||||
|
allow(Rails.logger).to receive(:info)
|
||||||
|
expect(Rails.logger).to receive(:info).with("{\"message\":\"CursorConnection: using deprecated order [#{admin.email}]\",\"user_id\":#{admin.user.id}}")
|
||||||
|
|
||||||
expect(gql_errors).to be_nil
|
expect(gql_errors).to be_nil
|
||||||
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
|
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
|
||||||
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_falsey
|
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_falsey
|
||||||
|
@ -232,6 +238,9 @@ describe API::V2::GraphqlController do
|
||||||
let(:end_cursor) { cursor_for(dossier2, order_column) }
|
let(:end_cursor) { cursor_for(dossier2, order_column) }
|
||||||
|
|
||||||
it {
|
it {
|
||||||
|
allow(Rails.logger).to receive(:info)
|
||||||
|
expect(Rails.logger).to receive(:info).with("{\"message\":\"CursorConnection: using deprecated order [#{admin.email}]\",\"user_id\":#{admin.user.id}}")
|
||||||
|
|
||||||
expect(gql_errors).to be_nil
|
expect(gql_errors).to be_nil
|
||||||
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
|
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
|
||||||
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_truthy
|
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_truthy
|
||||||
|
|
Loading…
Reference in a new issue