I'm trying to get a count of all products uploaded in the last 30 days per collection

Yes and also, Your Liquid code will generate the error “The rendered liquid was too large or had too many assignments” if it processes too much data at once. The Shopify Admin API or ShopifyQL are the better options for this operation because Liquid is a server-side templating language that has restrictions on loops and assignments.