Get job count for entire flow

Post Reply
ericnd01
Newbie
Posts: 15
Joined: Fri Sep 15, 2017 1:17 am

Get job count for entire flow

Post by ericnd01 »

Is there a way (via scripting or otherwise) to get a count of all current jobs being processed in a flow? Or is there a way to get a job count of each element? I am trying to find a way to run an external script only when a particular flow is not longer processing files.

I'm playing around with GlobalData and incrementing and decrementing a counter but I'm concerned about accuracy when a job fails, Switch crashes, or any other number of factors that could cause the counter to be off.

Any other approaches to accomplish this task are welcome.

Thanks!
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Get job count for entire flow

Post by Padawan »

Have you worked with Switch dashboards before? If not, then I would advise you to check the documentation on them:
https://www.enfocus.com/manuals/UserGui ... rview.html

They allow to give you a visual overview of all the jobs in all of the flows. By default you have live information of all jobs (which you currently need) and if you buy the Reporting module you have historical information.

You can access all the information from the dashboards using the REST API. This way you can request how many jobs are in which flows:
https://www.enfocus.com/manuals/Develop ... ardGraphQL

I'm not sure if you will be able to know which jobs are in which elements, but you could setup flow stages. You will certainly be able to know which flows are in which flow stages since the dashboards rely heavily on that.
https://www.enfocus.com/manuals/UserGui ... stage.html
ericnd01
Newbie
Posts: 15
Joined: Fri Sep 15, 2017 1:17 am

Re: Get job count for entire flow

Post by ericnd01 »

The Dashboards looks like it would do what I need, but we don't own the module. For this project, the price isn't justifiable. Also, the way in which we use Switch, the Dashboards wouldn't get used much. Damn... so close, too. I don't need to know the job status for each element, just the entire flow (minus Problem Jobs and Recycle Bins since those are no longer processing).
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Get job count for entire flow

Post by Padawan »

Based on your original description you don't need to buy any module.

You say: "Is there a way (via scripting or otherwise) to get a count of all current jobs being processed in a flow? "
You can get all current job information using the functionality the core module provides.

If you would need information on the count of all jobs who have been processed in a flow in the past, then you would need the reporting module.
ericnd01
Newbie
Posts: 15
Joined: Fri Sep 15, 2017 1:17 am

Re: Get job count for entire flow

Post by ericnd01 »

I started playing around with the API and was able to get the information, thank you. I've stumbled onto another potential issue: if a job is deleted using Switch Designer, it still shows "processing" in the status results for Job:List. Ideally, I wouldn't be deleting jobs in this manner, but it does happen when things get stuck. Is there a way to clear/reset/reload the job listing for the flow? Does it eventually clear itself out?
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Get job count for entire flow

Post by Padawan »

I think that's a question you better ask to Enfocus Support.
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Get job count for entire flow

Post by freddyp »

You can use the Switch REST API to query active jobs with a certain flow stage in a certain flow. Look at the GraphQL section of:
https://www.enfocus.com/manuals/Develop ... ardGraphQL. To query live jobs you do not need the Reporting Module. When the query returns that there are no jobs in that flow stage for that flow you can do your thing.
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Get job count for entire flow

Post by Padawan »

Now that I think of it, I think you can cleanup the jobs which you manually removed via Switch Designer via menu File/Cleanup Application data (or restarting Switch Server). Can you try that?
ericnd01
Newbie
Posts: 15
Joined: Fri Sep 15, 2017 1:17 am

Re: Get job count for entire flow

Post by ericnd01 »

freddyp wrote: Thu Jul 25, 2019 8:52 am You can use the Switch REST API to query active jobs with a certain flow stage in a certain flow. Look at the GraphQL section of:
https://www.enfocus.com/manuals/Develop ... ardGraphQL. To query live jobs you do not need the Reporting Module. When the query returns that there are no jobs in that flow stage for that flow you can do your thing.
This works perfectly! Thank you! Also works without needing Submit points and updates quickly.

Here is the cURL command I used if anyone is interested (the escape characters got a little ridiculous):

Code: Select all

curl -X POST http://127.0.0.1:51088/api/v1/graphql -H 'Authorization: Bearer xxxxxxxx' -H 'Content-Type: application/json' -d '{"query": "query { jobs(filter: \"{\\\"and\\\":[{\\\"flow\\\":{\\\"is\\\":\\\"testflow\\\"}}]}\") { count jobs { name } }}"}'
Post Reply