inigo / octopusviz

0 stars 0 forks source link

Connect data for graph to backend #5

Open sweep-ai[bot] opened 1 year ago

sweep-ai[bot] commented 1 year ago

PR Feedback: πŸ‘Ž

Description

This PR modifies the index.scala.html file to retrieve JSON data from the /data/consumption REST endpoint defined in JsonDataRoutes.scala and uses that data as the source for the trace1 Plotly scatter graph. It also adds a new test case in JsonDataRoutesTest.scala to ensure that the /data/consumption endpoint returns data in the correct format for the graph.

Summary of Changes

Please review and merge these changes.

Fixes #3.


πŸŽ‰ Latest improvements to Sweep:


πŸ’‘ To get Sweep to edit this pull request, you can:

sweep-ai[bot] commented 1 year ago

Sandbox Executions

trunk fmt src/main/twirl/views/index.scala.html || exit 0 1/2 βœ“
  FAILURES  
 prettier  src/main/twirl/views/index.scala.html  .trunk/out/vCGFq.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 0 files
βœ– No issues, 1 failure
trunk check --fix --print-failures src/main/twirl/views/index.scala.html 2/2 ❌ (`1`)
  ISSUES  
src/main/twirl/views/index.scala.html:95:1
 95:1  high   trailing whitespace.  git-diff-check/error
  FAILURES  
 prettier  src/main/twirl/views/index.scala.html  .trunk/out/tCUIR.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
βœ– 1 new issue
# .trunk/out/tCUIR.yaml
trunk_cli_version: 1.17.2
title: prettier exited with exit_code=2
report:
  - prettier exited with exit_code=2
  - linter:
      command: |
        /root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules/.bin/prettier -w src/main/twirl/views/index.scala.html
      stdin_path: (none)
      run_from: /tmp/trunk-0/2lbTP3/aRdxv9
      timeout: 10m
      rerun: (cd /tmp/trunk-0/2lbTP3/aRdxv9; env -i PATH=/root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules/.bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3/bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NODE_PATH=/root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules HOME=/root /root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules/.bin/prettier -w src/main/twirl/views/index.scala.html)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 2
      stdout: (none)
      stderr: |
        [error] src/main/twirl/views/index.scala.html: SyntaxError: Unexpected closing tag "script". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (155:9)
        [error]   153 |
        [error]   154 |
        [error] > 155 |         
        [error]       |         ^^^^^^^^^
        [error]   156 |     
        [error]   157 | 
    parser: |
      (none)

trunk fmt src/main/twirl/views/index.scala.html || exit 0 1/2 βœ“
  FAILURES  
 prettier  src/main/twirl/views/index.scala.html  .trunk/out/B1HeS.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 0 files
βœ– No issues, 1 failure
trunk check --fix --print-failures src/main/twirl/views/index.scala.html 2/2 ❌ (`1`)
  FAILURES  
 prettier  src/main/twirl/views/index.scala.html  .trunk/out/TS4Nd.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
βœ– No issues, 1 failure
# .trunk/out/TS4Nd.yaml
trunk_cli_version: 1.17.2
title: prettier exited with exit_code=2
report:
  - prettier exited with exit_code=2
  - linter:
      command: |
        /root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules/.bin/prettier -w src/main/twirl/views/index.scala.html
      stdin_path: (none)
      run_from: /tmp/trunk-0/DbL2hM/4nJdK6
      timeout: 10m
      rerun: (cd /tmp/trunk-0/DbL2hM/4nJdK6; env -i PATH=/root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules/.bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3/bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOME=/root NODE_PATH=/root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules /root/.cache/trunk/tools/prettier/3.0.3-f40a31f1cf22ae011727ab1e40e55171/node_modules/.bin/prettier -w src/main/twirl/views/index.scala.html)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 2
      stdout: (none)
      stderr: |
        [error] src/main/twirl/views/index.scala.html: SyntaxError: Unexpected closing tag "script". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (137:9)
        [error]   135 |
        [error]   136 |
        [error] > 137 |         
        [error]       |         ^^^^^^^^^
        [error]   138 |     
        [error]   139 | 
    parser: |
      (none)

trunk fmt src/main/twirl/views/index.scala.html || exit 0 1/2 βœ“
 βœ” Formatted src/main/twirl/views/index.scala.html
Re-checking autofixed files...

Checked 1 file
βœ” No issues
trunk check --fix --print-failures src/main/twirl/views/index.scala.html 2/2 βœ“
Checked 1 file
βœ” No issues

trunk fmt src/main/twirl/views/index.scala.html || exit 0 1/2 βœ“
Checked 1 file
βœ” No issues
trunk check --fix --print-failures src/main/twirl/views/index.scala.html 2/2 βœ“
Checked 1 file
βœ” No issues

trunk fmt src/main/twirl/views/index.scala.html || exit 0 1/2 βœ“
Checked 1 file
βœ” No issues
trunk check --fix --print-failures src/main/twirl/views/index.scala.html 2/2 βœ“
Checked 1 file
βœ” No issues

trunk fmt src/test/scala/net/surguy/octopusviz/http/JsonDataRoutesTest.scala || exit 0 1/2 βœ“
Found no applicable linters for the requested path
trunk check --fix --print-failures src/test/scala/net/surguy/octopusviz/http/JsonDataRoutesTest.scala 2/2 βœ“
Checked 1 file
βœ” No issues

sweep-ai[bot] commented 1 year ago

Apply Sweep Rules to your PR?

sweep-ai[bot] commented 1 year ago

The command: Run bin/sbt test yielded the following error: ##[error]Process completed with exit code 1. Here are the logs:

[info] welcome to sbt 1.9.6 (Eclipse Adoptium Java 21.0.1)
[info] loading settings for project octopusviz-build from plugins.sbt ...
[info] loading project definition from /home/runner/work/octopusviz/octopusviz/project
[info] loading settings for project root from build.sbt ...
[info] set current project to octopus-energyviz (in build file:/home/runner/work/octopusviz/octopusviz/)
[info] compiling 13 Scala sources to /home/runner/work/octopusviz/octopusviz/target/scala-3.3.1/classes ...
[error] /home/runner/work/octopusviz/octopusviz/src/main/twirl/views/index.scala.html:1:29: end of toplevel definition expected but '@' found
[error] @import java.time.LocalDate @import net.surguy.octopusviz.http.DateUtils._
[error]                             ^
[error] /home/runner/work/octopusviz/octopusviz/src/main/twirl/views/index.scala.html:20:32: Not found: formatDate
[error] 
[error] Explanation
[error] ===========
[error] The identifier for `formatDate` is not bound, that is,
[error] no declaration for this identifier can be found.
[error] That can happen, for example, if `formatDate` or its declaration has either been
[error] misspelt or if an import is missing.
[error]       Energy consumption from @formatDate(startDate) to @formatDate(endDate)
[error]                                ^
[error] /home/runner/work/octopusviz/octopusviz/src/main/twirl/views/index.scala.html:20:58: Not found: formatDate
[error] 
[error] Explanation
[error] ===========
[error] The identifier for `formatDate` is not bound, that is,
[error] no declaration for this identifier can be found.
[error] That can happen, for example, if `formatDate` or its declaration has either been
[error] misspelt or if an import is missing.
[error]       Energy consumption from @formatDate(startDate) to @formatDate(endDate)
[error]                                                          ^
[error] three errors found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 14 s, completed Nov 10, 2023, 10:31:15β€―PM

sweep-ai[bot] commented 1 year ago

πŸš€ Wrote Changes

Done.

inigo commented 1 year ago

There are some parts of this that are almost correct, but mostly this is wrong.

There are unnecessary changes to the file, particularly the imports and header, that mean that the code no longer compiles.

The comments are re-ordered in the head, such that they no longer make sense.

var trace1 and other code is now duplicated, so there are three copies of it.

The fetch is approaching correct, but doesn't deal with the async retrieval.

It's good to add a test for the route, but without adding a mock as well, it's unlikely to be correct.

sweep-ai[bot] commented 1 year ago

πŸš€ Wrote Changes

Done.