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

moved subselects to "from" clause #2464

Merged

Conversation

coreGreenberet
Copy link
Contributor

just a small simplification on the estimated mileage calculation

instead of 4 subselects I've moved the tables to the "from" clause.

From:

SELECT
	convert_km((((SELECT odometer FROM last_position) - (SELECT odometer	FROM first_position)) /
	EXTRACT(days FROM (SELECT date FROM last_position) - (SELECT date	FROM first_position)) * 
	365)::numeric, '$length_unit') AS "mileage_$length_unit";

To:

SELECT
	convert_km(((lp.odometer - fp.odometer) /
	EXTRACT(days FROM lp.date - fp.date) * 
	365)::numeric, '$length_unit') AS "mileage_$length_unit" from first_position as fp, last_position as lp;

Copy link
Collaborator

@adriankumpf adriankumpf left a comment

Choose a reason for hiding this comment

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

Nice one!

@adriankumpf adriankumpf merged commit 965381a into teslamate-org:master Feb 18, 2022
adriankumpf added a commit to fmossott/teslamate that referenced this pull request Apr 22, 2022
* master:
  Update timeline.json (teslamate-org#2601)
  Update charging-stats.json (teslamate-org#2566)
  Update to projects page (doc/website) (teslamate-org#2518)
  Update States top row panels height (teslamate-org#2487)
  Do no start EPMD
  Bump grafana/grafana from 8.4.1 to 8.4.5 in /grafana
  Bump docker/build-push-action from 2.9.0 to 2.10.0
  Bump erlef/setup-beam from 1.10 to 1.11
  Bump docker/login-action from 1.12.0 to 1.14.1
  Bump actions/cache from 2.1.7 to 3.0.1
  Bump website deps
  Bump deps
  Bump actions/checkout from 2.4.0 to 3
  Restart stream process if token expired
  Update charging-stats.json (teslamate-org#2481)
  Fix typo
  Update POT files
  Update CHANGELOG
  Move encryption key warning into .container
  Encrypt API tokens (teslamate-org#2360)
  Update frontend deps
  DC charge curve scatter graph (teslamate-org#2093)
  Update CHANGELOG
  Bump Grafana to 8.4.1
  Added panel with the cost of charges in SuC (teslamate-org#2448)
  Add datasource to table and map panels. (teslamate-org#2391)
  Update charging-stats.json (teslamate-org#2461)
  moved subselects to "from" clause (teslamate-org#2464)
  Added ProxyPreserveHost On to the Grafana entries in Apache2 config (teslamate-org#2471)
  Render Trip piechart legend (teslamate-org#2473)
  Bump follow-redirects from 1.14.7 to 1.14.8 in /website
  Update default.po (teslamate-org#2479)
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.

2 participants