a2e45b8fdde315b756691b4ae573ad55f55dc002,homeassistant/components/history.py,,get_states,#Any#Any#Any#,93

Before Change



    if entity_ids is not None:
        where += "AND entity_id IN ({}) ".format(
            ",".join(["?"] * len(entity_ids)))
        where_data.extend(entity_ids)

    query = 

After Change


    from sqlalchemy import and_, func

    states = recorder.get_model("States")
    most_recent_state_ids = recorder.query(
        func.max(states.state_id).label("max_state_id")
    ).filter(
        (states.created >= run.start) &
        (states.created < utc_point_in_time)
    )

    if entity_ids is not None:
        most_recent_state_ids = most_recent_state_ids.filter(
            states.entity_id.in_(entity_ids))

    most_recent_state_ids = most_recent_state_ids.group_by(
        states.entity_id).subquery()

    query = recorder.query("States").join(most_recent_state_ids, and_(
        states.state_id == most_recent_state_ids.c.max_state_id))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

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: get_states


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


Project Name: snorkel-team/snorkel
Commit Name: 4b5bec4559dcb5d294a985ce45a425a05fe7ef0e
Time: 2016-09-03
Author: ajratner@gmail.com
File Name: snorkel/annotations.py
Class Name: AnnotationManager
Method Name: load