Rendering Multiple Recipe for Single Report



  • Hello,
    For my use case, we want to give single report into multiple format ("html", "chrome-pdf" & "html-to-xlsx").
    As my system is very real-time, so generating different recipe one after another can sometime leads to data anomaly.
    So, is there any way to pass array of recipes in /api/reports API (https://jsreport.net/learn/api#rendering-report).
    Ex.
    URL: https://jsreport-host.com/api/report
    METHOD: POST

    {
    "template":{"name":"User Access","recipe":["html","chrome-pdf","html-to-xlsx"]},
    "options":{"reports":{"save":true,"async":true}},
    "filters":{"login":["jerome"]}
    }
    

    Please help. Thanks in advance.



  • Thats not supported natively.

    You can implement a custom jsreport script that renders multiple reports and combines them in single output like this
    https://playground.jsreport.net/w/anon/zsSpwLoJ

    As my system is very real-time, so generating different recipe one after another can sometime leads to data anomaly.

    What you mean here exactly?



  • Thanks. I will try above playground link.

    As my system is very real-time, so generating different recipe one after another can sometime leads to data anomaly.
    Means, We generate reports from our database's current state. where report script fetches the data from dataservices (MongoDB). So, data changes very fast.
    Ex. At 12:30AM, Last 5 min User Activity Data

    [
      {
        "event": "login",
        "data": {
          "username": "jerome",
          "device": "mobile"
        }
      },
      {
        "event": "login",
        "data": {
          "username": "sarah",
          "device": "mobile"
        }
      },
      {
        "event": "login",
        "data": {
          "username": "joe",
          "device": "mobile"
        }
      }
    ]
    
    

    At 12:31AM,

    [
      {
        "event": "login",
        "data": {
          "username": "jerome",
          "device": "mobile"
        }
      },
      {
        "event": "login",
        "data": {
          "username": "sarah",
          "device": "mobile"
        }
      },
      {
        "event": "login",
        "data": {
          "username": "joe",
          "device": "mobile"
        }
      },
    // New Entity
      {
        "event": "login",
        "data": {
          "username": "ali",
          "device": "mobile"
        }
      }
    ]
    

    So for past couple months, I was looping the recipes. where I was awaiting every recipe response and then storing the result in one entity. but if one recipe takes little more time, then next recipe will receive wrong data.
    To overcome, I can do Promise.all for parallel calls at the same time. But wanted to check if jsreport has any native feature like this.



  • This post is deleted!


  • where report script fetches the data from dataservices (MongoDB). So, data changes very fast.

    I see, perhaps you should load the data only for the first report and temporarily store them separately so the following reports can use the same.



  • True, but we allow our customer to create custom reports using internal APIs, which will be displayed in UI. So storing initial data will be tricky. That's why I was hoping that somehow jsreports saves the returned data of script and use different recipe.
    But I will use above solution for now. Thanks.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.