HubDB request limit: hubdb_table_row in a for-loop with data from related tables

SOLVE
MikeBeatwoot
Participant

Hey,

i am struggling to understand what is the right way to solve my problem. i want to display all blog entries and add some related informations from connected tables (customer und products). This is causing too many requests and runs way to fast in the page limit of requests.

How can I change my code to not run in this limit? It would be amazing if you guys could me out.

{% for post in post_listing %}
{% set product_id = post.widgets.choice_product_id.body.value %}
{% set product = hubdb_table_row(4024611, product_id) %}
{% set customer_id = post.widgets.choice_customer_id.body.value %}
{% set customer = hubdb_table_row(2697665, customer_id) %}
<article>
<a class="testimonial-listing-card" href="{{ post.absolute_url }}">
{% if post.featured_image %} <img class="testimonial_featured-image" src="{{ post.featured_image }}" alt="{{ post.featured_image.alt }}"> 
</a>
<div class="testimonial-card-text-overlay">
<a href="{{ post.absolute_url }}"><img src="{{ customer.logo_de.url }}" alt="{{ customer.name }} {{ customer.name|pprint }} Logo" class="testimonial-card-logo"> <h3>{{ post.name }}</h3> </a> 
</div>
</article>
{% endfor %} 

Best wishes,
Mike

 

 

1 Accepted solution

Accepted Solutions
Kevin-C
Solution
Recognized Expert

Hey @MikeBeatwoot 

 

So I was digging into serverless functions last night and it made me think of your blocker.

 

I think your case is a perfect usecase for making API calls using the serverless functions!

 

This getting started doc can get you moving rather quickly!

View solution in original post

4 Replies 4
Kevin-C
Recognized Expert

Hey @MikeBeatwoot 

 

So I'd imagine you're hitting the 10 calls per second limit rather fast, especially since you're making 2 calls per loop iteration!

 

Since we know the length of post_listing I wonder if you could create a sort of pagination using a query param to track/get the position in the data?

MikeBeatwoot
Participant

I really would like to show all entries on one page with a continuos loader. I could remove the first call, but still struggling with the customer call. Is there a way to call all entries from 2 columns (id and url) in a dict?

0 Upvotes
MikeBeatwoot
Participant

i am getting closer to it

 

{% set customer_logos = [] %}

{% for row in hubdb_table_rows(2697665) %}
{% do customer_logos.append([row.hs_id, row.logo_de.url]) %}
{% endfor %}
		
{{ customer_logos }}

.
Got an array with a list of all ids and logo urls. but how can i filter the array to get only the logo_url of a single id from the array. 

Kevin-C
Solution
Recognized Expert

Hey @MikeBeatwoot 

 

So I was digging into serverless functions last night and it made me think of your blocker.

 

I think your case is a perfect usecase for making API calls using the serverless functions!

 

This getting started doc can get you moving rather quickly!

View solution in original post