a2e45b8fdde315b756691b4ae573ad55f55dc002,homeassistant/components/history.py,,state_changes_during_period,#Any#Any#Any#,72

Before Change


def state_changes_during_period(start_time, end_time=None, entity_id=None):
    Return states changes during UTC period start_time - end_time.
    where = "last_changed=last_updated AND last_changed > ? "
    data = [start_time]

    if end_time is not None:
        where += "AND last_changed < ? "
        data.append(end_time)

After Change


def state_changes_during_period(start_time, end_time=None, entity_id=None):
    Return states changes during UTC period start_time - end_time.
    states = recorder.get_model("States")
    query = recorder.query("States").filter(
        (states.last_changed == states.last_updated) &
        (states.last_changed > start_time))

    if end_time is not None:
        query = query.filter(states.last_updated < end_time)

    if entity_id is not None:
        query = query.filter_by(entity_id=entity_id.lower())

    states = recorder.execute(
        query.order_by(states.entity_id, states.last_updated))

    return states_to_json(states, start_time, entity_id)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: home-assistant/home-assistant
Commit Name: a2e45b8fdde315b756691b4ae573ad55f55dc002
Time: 2016-07-02
Author: rhooper@toybox.ca
File Name: homeassistant/components/history.py
Class Name:
Method Name: state_changes_during_period


Project Name: HazyResearch/fonduer
Commit Name: b9f40fb90f0ad5d9dca8168db4040462a46510a8
Time: 2018-08-06
Author: lwhsiao@stanford.edu
File Name: tests/candidates/test_candidates.py
Class Name:
Method Name: test_cand_gen


Project Name: home-assistant/home-assistant
Commit Name: a2e45b8fdde315b756691b4ae573ad55f55dc002
Time: 2016-07-02
Author: rhooper@toybox.ca
File Name: homeassistant/components/history.py
Class Name:
Method Name: get_significant_states