• Hello,

    I moved a podcast from Site A to Site B. Of course, this made post IDs change. So I added post_name to wp_ssp_stats and got the slug.

    Then I imported wp_ssp_stats from Site A in Site B (without the id column so MySQL gets them entries a new and unique ID. And then I went the other way round and got the post ID using the post_name and updated it.

    What happens now is that the graph in the stat goes crazy. It apparently gets the results within the range ordered by ID or something. So it happens that the graph mixes dates in between.

    And here’s the fix:

    seriously-simple-stats/php/classes/class-ssp-stats.php
    find (line 761):
    $sql = $wpdb->prepare( "SELECT date FROM $this->_table WHERE date BETWEEN %d AND %d $episode_id_where", $this->start_date, $this->end_date );

    replace with:
    $sql = $wpdb->prepare( "SELECT date FROM $this->_table WHERE date BETWEEN %d AND %d $episode_id_where ORDER BY date ASC", $this->start_date, $this->end_date );

    Now the graph is as expected.

    I hacked this into my copy over at Site B and would be glad if you could apply this as well. It has no side-effects in normal operations, but it allows imports of this kind ??

    Thank you!
    Alduin

    EDIT:
    This change, which only adds the “ORDER BY date ASC” really, should be applied to all queries with a date range that might result in a graph.

    • This topic was modified 4 years, 12 months ago by alduinwf.
  • The topic ‘Bug in graph when importing data’ is closed to new replies.