Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Generator now shows data in fixed time mode #4883

Merged
merged 13 commits into from
Mar 21, 2022
Merged

Event Generator now shows data in fixed time mode #4883

merged 13 commits into from
Mar 21, 2022

Conversation

scottbell
Copy link
Contributor

@scottbell scottbell commented Feb 21, 2022

Closes #4879

Describe your changes:

Changed the event generator to use passed start time instead of using Date.now. Also added a test to ensure this works for dates long in the past.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Is this change backwards compatible? For example, developers won't need to change how they are calling the API or how they've extended core plugins such as Tables or Plots.

Author Checklist

  • Changes address original issue?
  • Unit tests included and/or updated with changes?
  • Command line build passes?
  • Has this been smoke tested?
  • Testing instructions included in associated issue?

Reviewer Checklist

  • Changes appear to address issue?
  • Changes appear not to be breaking changes?
  • Appropriate unit tests included?
  • Code style and in-line documentation are appropriate?
  • Commit messages meet standards?
  • Has associated issue been labelled unverified? (only applicable if this PR closes the issue)
  • Has associated issue been labelled bug? (only applicable if this PR is for a bug fix)

@scottbell scottbell changed the title fixed issue and added tests Event Generator now shows data in fixed time mode. #4879 Feb 21, 2022
@scottbell scottbell changed the title Event Generator now shows data in fixed time mode. #4879 Event Generator now shows data in fixed time mode Feb 21, 2022
@@ -33,7 +33,7 @@ class EventTelemetryProvider {

generateData(firstObservedTime, count, startTime, duration, name) {
const millisecondsSinceStart = startTime - firstObservedTime;
const utc = Math.floor(startTime / duration) * duration;
const utc = startTime + (count * duration);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allows any request to show data. previous incarnation was showing data well into the future

@@ -75,15 +75,15 @@ class EventTelemetryProvider {
const duration = domainObject.telemetry.duration * 1000;
const size = options.size ? options.size : this.defaultSize;
const data = [];
const firstObservedTime = Date.now();
const firstObservedTime = options.start;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use the start request

let count = 0;

if (options.strategy === 'latest' || options.size === 1) {
start = end;
}

while (start <= end && data.length < size) {
const startTime = Date.now() + count;
const startTime = options.start + count;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

often the time window the user has is far in the past of Date.now, so just use the start that was requested

@@ -1,3 +1,2 @@
const testsContext = require.context('.', true, /\/(src|platform|\.\/example)\/.*Spec.js$/);

const testsContext = require.context('.', true, /^\.\/(src|example)\/.*Spec.js$/);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted regex so that we don't pick up:
./node_modules/fooPackage/src/FooSpec.js
./node_modules/fooPackage/example/FooSpec.js
but we do pick up:
./example/eventGenerator/pluginSpec.js

As the example directory is often released to users, it seems like it should be covered by tests

@codecov
Copy link

codecov bot commented Feb 21, 2022

Codecov Report

Merging #4883 (1ed540d) into master (0df3373) will decrease coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4883      +/-   ##
==========================================
- Coverage   50.45%   50.34%   -0.11%     
==========================================
  Files         497      510      +13     
  Lines       18401    18657     +256     
  Branches     1657     1657              
==========================================
+ Hits         9284     9393     +109     
- Misses       8702     8850     +148     
+ Partials      415      414       -1     
Impacted Files Coverage Δ
example/eventGenerator/EventTelemetryProvider.js 96.96% <100.00%> (ø)
indexTest.js 100.00% <100.00%> (ø)
example/generator/GeneratorProvider.js 27.58% <0.00%> (ø)
example/exampleUser/ExampleUserProvider.js 80.00% <0.00%> (ø)
example/generator/GeneratorMetadataProvider.js 71.42% <0.00%> (ø)
example/generator/plugin.js 20.00% <0.00%> (ø)
example/generator/StateGeneratorProvider.js 22.22% <0.00%> (ø)
example/eventGenerator/EventMetadataProvider.js 33.33% <0.00%> (ø)
example/exampleUser/exampleUserCreator.js 100.00% <0.00%> (ø)
example/generator/SinewaveLimitProvider.js 45.83% <0.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0df3373...1ed540d. Read the comment docs.

@@ -3,7 +3,7 @@
{
"name": "descriptionRegexp",
"config": {
"regexp": "x] Testing instructions",
"regexp": "(?i)x] Testing instructions",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@unlikelyzero This was tripping me up as I was using X to check the boxes in the template instead of x

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing this. You're not the only one who was using the INCORRECT markdown format ;)

@jvigliotta
Copy link
Contributor

@jvigliotta to take a look.

Copy link
Contributor

@jvigliotta jvigliotta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Nice work!

@jvigliotta jvigliotta merged commit 28d5d72 into master Mar 21, 2022
@jvigliotta jvigliotta deleted the mct4879 branch March 21, 2022 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event Generator does not show data in fixed time mode.
3 participants