humanmade / Simple-Instant-Articles-for-Facebook

Add support for Facebook Instant Articles to your WordPress site.
7 stars 0 forks source link

Remove meta query. Skip hidden/sponsored in feed #58

Closed mattheu closed 8 years ago

mattheu commented 8 years ago

This meta query doesn't scale. Even before adding the bit for _lawrence_hide_on_fb_ia_feed, the feed was taking a long time to generate. 10+ seconds. Too long for Facebook and they are reporting errors. (Not a total deal breaker, they will retry after 3 minutes and since we cache for 5 - this works OK)

Quick solution - just skip these posts in the loop. Should be fine because there won't be too many, and FB will probably handle having fewer than 10 posts in the feed no problem.

Longer term solution - we need to do better querying.

dashaluna commented 8 years ago

We can save a meta value for a post to be exclude it from feed - on save post, with all the different conditions, will be just one meta value.

The performance probably will be similar to initial case - where there was one meta value lookup.

mattheu commented 8 years ago

Could do that. Although right now its too slow with just the following. However I think if we could do an EXISTS check it would be better.

array(
    'relation' => 'OR',
    array(
        'key'     => '_format_sponsored_link',
        'value'   => '',
        'compare' => '=',
    ),
    array(
        'key'     => '_format_sponsored_link',
        'compare' => 'NOT EXISTS',
    ),
),