join the community conversations

5000+
active members

Clear Your Finished Jobs

Comments

4 comments

  • Avatar
    Tobias Månsson
    inriver champion

    Running your code gave me "fetch(...).done is not a function", but changing "done" to "then" worked. 

    1
  • Avatar
    Daniel Johnson

    Good catch Tobias Månsson. I've updated the code.

    0
  • Avatar
    Jared Songster
    Conversation Starter

    Replace 'Finished' with 'Cancelled' or 'Error' to clear those jobs. 

    1
  • Avatar
    Michael W. Ray

    I took what Jared gave and updated the script to take care of it without making changes.  You may need to run it twice to clear everything up as some things were not caught on the first round.

    To do this in Chrome, click "F12" key, click "Console", type "allow pasting" in the console window, copy and paste below code into the console window, hit "enter" key.

     

    fetch("/api/LongRunningJob")
      .then(r=>r.json())
      .then(d=>{
          if (!Array.isArray(d)) {
         return;
    }
    d.forEach((item)=>{
    if (/^Finished/.test(String(item.State))) {
    fetch(`/api/LongRunningJob/${item.Id}`, { method: "DELETE" })
    .then(console.info.bind(console))
    .catch(console.error.bind(console));
    }
    });

    d.forEach((item)=>{
    if (/^Cancelled/.test(String(item.State))) {
    fetch(`/api/LongRunningJob/${item.Id}`, { method: "DELETE" })
    .then(console.info.bind(console))
    .catch(console.error.bind(console));
    }
    });

    d.forEach((item)=>{
    if (/^Error/.test(String(item.State))) {
    fetch(`/api/LongRunningJob/${item.Id}`, { method: "DELETE" })
    .then(console.info.bind(console))
    .catch(console.error.bind(console));
    }
    });

    });

     

    1

Please sign in to leave a comment.