Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't see anything obviously wrong with your code. Since we've already established that there are no errors, my advice would be to add more logging.info calls higher up to see which if statement is evaluating to false, or which for loop is iterating over an empty set. Also, have you confirmed that crimechecker is successfully setting new crime stories to True? It doesn't sound like you've determined which of your two cron jobs is at fault.</p> <p>More fundamentally, I think you should re-consider the basic design of this task. Let's classify it as 3 steps:</p> <ol> <li>User creates a new Article entity with a title and body</li> <li>If the body contains certain keywords, flag it as containing a crime.</li> <li>If it contains a crime, create a corresponding Story entity.</li> </ol> <p>Why not just do all of this work in one handler when the article is saved? Why break it out three distinct parts? Besides making the operation complex, your 2nd cron job is also inefficient at scale. You're fetching every crime story since the beginning of time and doing one query for each to see if there's a corresponding story. If you accumulate any significant number of articles, this won't complete in time.</p> <p>If you're worried about the performance impact of doing all of these tasks when the article is first saved, use the task queue. When the article is first saved, create one task to scan it for crime keywords. If the keywords are found, create one task to store the corresponding story entity. Pass the entity key around in the task parameters so you don't have to query for anything.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload