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

Align GasConsumption.read_at to represent the start of hour #40

Closed
dennissiemensma opened this issue Feb 5, 2016 · 8 comments
Closed
Milestone

Comments

@dennissiemensma
Copy link
Member

Originally reported by: Dennis Siemensma (Bitbucket: dennissiemensma, GitHub: dennissiemensma)


Currently GasConsumption.read_at represents the passed hour read, so the end timestamp of the hour. We should make that the start of the hour instead.

Now

read_at = 22:00 = reading was between 21:00 and 22:00

Aligned

read_at = 21:00 = reading was between 21:00 and 22:00

Should not be very hard to alter, as migrations will be easy in the database (-1 hour).


@dennissiemensma dennissiemensma modified the milestone: 0.9 (β) Feb 7, 2016
@dennissiemensma dennissiemensma modified the milestones: 0.9 (β), 1.1.0 Feb 7, 2016
@dennissiemensma
Copy link
Member Author

Very nice F() field:

    GasConsumption.objects.all().update(
        read_at=models.F('read_at') + timezone.timedelta(hours=hours_offset)
    )

@dennissiemensma
Copy link
Member Author

Running across a bug where statistics generation is halted when no gas data is found.

@dennissiemensma
Copy link
Member Author

Fixed it, by making gas optional, which was required anyway due to #34

@dennissiemensma
Copy link
Member Author

Refactored a bit so the ORM's queries made more sense:

MySQL:

(0.028) UPDATE `dsmr_consumption_gasconsumption` SET `read_at` = (`dsmr_consumption_gasconsumption`.`read_at` - INTERVAL '0 0:0:3600:0' DAY_MICROSECOND); args=()

PostgreSQL:

(0.027) UPDATE "dsmr_consumption_gasconsumption" SET "read_at" = ("dsmr_consumption_gasconsumption"."read_at" - '0 days 3600.000000 seconds'::interval); args=(datetime.timedelta(0, 3600),)

@dennissiemensma
Copy link
Member Author

Merged, along with bugfix for #50.

@dennissiemensma
Copy link
Member Author

Deployed.

@dennissiemensma
Copy link
Member Author

I've seem to have created a bug in calculating gas consumption, using the new logic.

  • When affected by the bug, the dashboard gas graph will no longer display usage.
  • The day usage (= diff) is however unaffected.

At least we still have te source readings to recalculate the consumption retroactive.

@dennissiemensma
Copy link
Member Author

Fixed bug and added migration to recalculate incorrect data.

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

No branches or pull requests

1 participant