Skip to content

Commit

Permalink
feature/appeals-39842 (#21864)
Browse files Browse the repository at this point in the history
* anusha/appeals-45976 (#21738)

* Change address format

* added rspec tests to cover hotfix

* testing for inclusion of expected values (addressLine1, etc.)

* rspec test -- wip

* still WIP

* Fix address tests.

* updated fakes

* Update internationalPostalCode

* appeals controller spec update

* http request changed and test

---------

Co-authored-by: Noelle Adkin <98478937+NoelleAd@users.noreply.github.com>
Co-authored-by: Anusha Palliyil <palliyil_anusha@bah.com>
Co-authored-by: Lauren Berry <berry_lauren@bah.com>

* lauren/APPEALS-39842 (#21739)

* Add scroll metrics start time fix and update metric message

* Add metrics attributes json in PdfPage constructor and add isPageVisible metric attribute

* Fix scroll message spacing

---------

Co-authored-by: laurenyj <44596134+laurenyj@users.noreply.github.com>

* noelle/appeals-39842 (#21740)

* Remove UUID from attrs sent_to metrics.

* Remove UUID from spec

* remove uuid from update_appellant job

---------

Co-authored-by: Noelle Adkin <98478937+NoelleAd@users.noreply.github.com>

* fix failing tests

---------

Co-authored-by: Noelle Adkin <98478937+NoelleAd@users.noreply.github.com>
Co-authored-by: Anusha Palliyil <palliyil_anusha@bah.com>
Co-authored-by: Lauren Berry <berry_lauren@bah.com>
Co-authored-by: laurenyj <44596134+laurenyj@users.noreply.github.com>
  • Loading branch information
5 people authored Jun 10, 2024
1 parent 5cb76aa commit 96db5b5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/controllers/metrics/v2/logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def create
private

def metrics_not_saved
render json: { error_code: "Metrics not saved for user" }, status: :unprocessable_entity
render json: { error_code: "Metrics not saved for user" }, status: :accepted
end

def allowed_params
Expand Down
3 changes: 1 addition & 2 deletions app/services/metrics_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def self.record(description, service: nil, name: "unknown", caller: nil)
app_name: app,
attrs: {
service: service,
endpoint: name,
uuid: uuid
endpoint: name
}
}
MetricsService.emit_gauge(sent_to_info)
Expand Down
30 changes: 12 additions & 18 deletions client/app/reader/PdfFile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export class PdfFile extends React.PureComponent {
file: this.props.file,
documentType: this.props.documentType,
prefetchDisabled: this.props.featureToggles.prefetchDisabled,
overscan: this.props.windowingOverscan
overscan: this.props.windowingOverscan,
isPageVisible: this.props.isVisible,
name: null
};
}

Expand Down Expand Up @@ -467,32 +469,24 @@ export class PdfFile extends React.PureComponent {
clearTimeout(this.scrollTimer);
}

this.scrollTimer = setTimeout(() => {
const scrollStart = performance.now();
const scrollStart = performance.now();

const data = {
overscan: this.props.windowingOverscan,
documentType: this.props.documentType,
pageCount: this.props.pdfDocument.numPages,
pageIndex: this.pageIndex,
prefetchDisabled: this.props.featureToggles.prefetchDisabled,
start: scrollStart,
end: performance.now()
};
this.scrollTimer = setTimeout(() => {
const scrollEnd = performance.now();
const scrollMessage = `Scroll to page ${this.currentPage + 1} (${(Math.round(this.scrollLeft * 100) / 100).toFixed(2)}, ${(Math.round(this.scrollTop * 100) / 100).toFixed(2)})`;

const posx = (Math.round(this.scrollLeft * 100) / 100).toFixed(2);
const posy = (Math.round(this.scrollTop * 100) / 100).toFixed(2);
this.metricsAttributes.name = scrollMessage;

storeMetrics(
this.props.documentId,
this.metricsAttributes,
{
message: `Scroll to position ${posx}, ${posy}`,
message: scrollMessage,
type: 'performance',
product: 'reader',
start: new Date(performance.timeOrigin + data.start),
end: new Date(performance.timeOrigin + data.end),
duration: data.start ? data.end - data.start : 0
start: new Date(performance.timeOrigin + scrollStart),
end: new Date(performance.timeOrigin + scrollEnd),
duration: scrollStart ? scrollEnd - scrollStart : 0
},
this.metricsIdentifier,
);
Expand Down
12 changes: 12 additions & 0 deletions client/app/reader/PdfPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export class PdfPage extends React.PureComponent {
this.isDrawing = false;
this.renderTask = null;
this.marks = [];

this.metricsAttributes = {
documentId: this.props.documentId,
numPagesInDoc: null,
pageIndex: this.props.pageIndex,
file: this.props.file,
documentType: this.props.documentType,
prefetchDisabled: this.props.featureToggles.prefetchDisabled,
overscan: this.props.windowingOverscan,
isPageVisible: this.props.isVisible,
name: null
};
}

getPageContainerRef = (pageContainer) => (this.pageContainer = pageContainer);
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/metrics/v2/logs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
end

context "with good request and metrics_monitoring feature OFF" do
it "does not create a metric and returns 422" do
it "does not create a metric and returns 202" do
expect(Metric).not_to receive(:create_metric_from_rest)
post :create, params: request_params_javascript
expect(response.status).to eq(422)
expect(response.status).to eq(202)
end
end
end
2 changes: 1 addition & 1 deletion spec/jobs/update_appellant_representation_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)
expect(MetricsService).to receive(:emit_gauge).with(
app_name: "queue_job",
attrs: { endpoint: "AppellantNotification.appeal_mapper", service: "queue_job", uuid: anything },
attrs: { endpoint: "AppellantNotification.appeal_mapper", service: "queue_job" },
metric_group: "service",
metric_name: "request_latency",
metric_value: anything
Expand Down
6 changes: 2 additions & 4 deletions spec/services/metrics_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
app_name: "other",
attrs: {
service: service,
endpoint: name,
uuid: anything
endpoint: name
}
)
expect(MetricsService).to receive(:increment_counter).with(
Expand Down Expand Up @@ -72,8 +71,7 @@
app_name: "other",
attrs: {
service: service,
endpoint: name,
uuid: anything
endpoint: name
}
},
start: anything,
Expand Down

0 comments on commit 96db5b5

Please sign in to comment.