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

Update to show kWh even if still charging #723

Closed
wants to merge 1 commit into from
Closed

Update to show kWh even if still charging #723

wants to merge 1 commit into from

Conversation

Dulanic
Copy link
Collaborator

@Dulanic Dulanic commented May 17, 2020

Will allow user to see the the amount charged even if still charging by using charges table instead of charge_processes.

Will allow user to see the the amount charged even if still charging by using charges table instead of charge_processes.
@Dulanic Dulanic closed this May 18, 2020
@Dulanic Dulanic deleted the patch-3 branch May 18, 2020 14:20
@Dulanic Dulanic restored the patch-3 branch May 19, 2020 20:22
@Dulanic
Copy link
Collaborator Author

Dulanic commented May 19, 2020

Didnt mean to close this,

@Dulanic Dulanic reopened this May 19, 2020
@@ -234,7 +234,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT charge_energy_added from charging_processes where id = $charging_process_id;",
"rawSql": "SELECT charge_energy_added from charges where id = $charging_process_id order by date desc fetch first 1 row only ;",
Copy link
Collaborator

Choose a reason for hiding this comment

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

id should be charging_process_id

Copy link
Collaborator

Choose a reason for hiding this comment

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

In rare cases charge_energy_added does not start a zero so that the total energy added is less than the last reported charge_energy_added (end_charge_energy_added - start_charge_energy_added to be precise). Therefore we should still prefer to display the value reported in the charging_processes table, for example:

WITH completed_charge AS (
	SELECT charge_energy_added
	FROM charging_processes
	WHERE id = $charging_process_id
),
in_progress_charge AS (
	SELECT charge_energy_added
	FROM charges
	WHERE charging_process_id = $charging_process_id
	ORDER BY date DESC FETCH FIRST 1 ROW ONLY
)
SELECT COALESCE(completed_charge.charge_energy_added, in_progress_charge.charge_energy_added)
FROM completed_charge
JOIN in_progress_charge on true

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, I messed up my repor and had closed out this branch... so I couldnt fix it. I will close this PR as I made a new one.

#744

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