[βœ… Solution] Count entries of a view

I would like to calculate the number of entries of these two views and then output them as a percentage. (I tried it with the API and a Tape-automation, but immediately run into limitations. :frowning:)
image

However, this only works as long as the view does not have many entries. 15 works, 300 does not, let alone +5000K entries.

Script:


Error with 300 entries:
image

Especially with regard to the Dashboards, there has to be some kind of straightforward solution?

Hi @Roman

Not a solution I am affraid but more of a confirmation that there seems to be a hard limit of 1000 records in a collection at least with one built via an automation:


Whichever way I build the collection my 3000+ view gets caped at 1000 records.

1 Like

Thanks for testing @Jason. So we have discovered another limit, in my case, however, the process does not even manage to count 300 entries.

I only want to analyze these entries and nothing more. That shouldn’t be that difficult.

1 Like

Thanks for sharing your issue @Roman - totally understand your use case.

Currently, workflow automation runs are not designed to process large amount of data within one single flow run. That is the reason why we limit the number of records to 1000, and further resource constraints such as limited memory could lead to issues when working with large record data sets at the same time.

Luckily, your use case is about counting the records only using a filter, rather than needing to load the whole data itself. There is indeed a trick that you can apply - the Tape API returns the total count when searching in an app, see the developer docs for more info.

Suggested solution

Indeed your case could be solved by converting your search action to code. Start from your code action, it would look similar to this one:

In my case above, I also applied the β€œlimit results” option, as we are indeed not interested in the data itself we can limit the queried records. The total count will still be the actual total.

Now, convert your action to code using the turn into option:

Be sure to also add variable using the β€œ+” button and name it total:

Screenshot 2024-04-04 at 20.06.30

Now inside the code editor find the line where the request is made, it should look similar to this one:

const { data: { records } } = await tape.Record.getManyFiltered({ appId: 17, limit: 1, filters: filters, }); 

change the first part to this:

const { data: { records, total } } ... 

and further assign your total variable below:

var_total = total;

The relevant code section would now look like this:

// ...
      // (1a) retrieve records via the API
      const { data: { records, cursor, total } } = await tape.Record.getManyFiltered({ appId: 17, limit: 1, filters: filters, }); 
      var_total = total;

// ...

Now, your total variable will contain the actual total count of your record search.

I know, this is little bit of work and should be made simpler on our end in the future. Hopefully, you will be able to solve your use case for now using this workaround. In the future we might expose this total using a dedicated variable.

Let me know how it goes - Happy building! :slight_smile:

Cheers
Tim

1 Like

I didn’t realize that you can do this with every module. This is a great way to explore undocumented parts of tape.
Thank you very much for the tip @Tim and your help. :pray:

Your solution works and the first mails have already been sent to our partners.

1 Like