a2e45b8fdde315b756691b4ae573ad55f55dc002,homeassistant/components/history.py,,get_states,#Any#Any#Any#,93
Before Change
if run is None:
return []
where = run.where_after_start_run + "AND created < ? "
where_data = [utc_point_in_time]
if entity_ids is not None:
where += "AND entity_id IN ({}) ".format(
",".join(["?"] * len(entity_ids)))
where_data.extend(entity_ids)
query =
SELECT * FROM states
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()
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 7
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: arviz-devs/arviz
Commit Name: 77fc2272e32e6302d34b80febdc1b8fdf49de61d
Time: 2018-10-27
Author: aloctavodia@gmail.com
File Name: arviz/plots/densityplot.py
Class Name:
Method Name: plot_density
Project Name: dpressel/mead-baseline
Commit Name: 1ecfdee633512081ad3fa40d9ed37aa3ac3d19c4
Time: 2018-09-20
Author: dpressel@gmail.com
File Name: python/baseline/model.py
Class Name: Classifier
Method Name: classify_text
Project Name: etal/cnvkit
Commit Name: 203ed6d1fda8de579c2bf311e5890dca05c14985
Time: 2016-12-10
Author: eric.talevich@gmail.com
File Name: cnvlib/target.py
Class Name:
Method Name: shorten_labels