Separating items on a list in individual database entries!

I have a list of numbers. How would I get these numbers as individual items in bubble?

Tnx

You need to provide way more info

For instance if you wanted to display those numbers you can set a repeating group to numbers and set the datasource to the list

Or possibly depending what your trying to do you could create a new thing (say saved_number) with a field this_number -> type number.
Every time you save a number create a new saved_number and put your number in this_number

Hi!

So it goes like this!

I have 2 date inputs and I have a javascript that gets a array between two dates. I am using Toolbox plugin to get this array from javascript and then I create a new list in bubble. I know how to use that in a repeating group. Trough that repeating group I am able to convert these dates to UNIX EPOCH timestamps in list form and display that in another repeating group.

The problem is I need these timestamps as separate items so I can call API with each timestamp individualy. Unless there is a way to call api using a list which I don’t think is possible.

I see more than one way to solve this.

One would be to separate the array into individual items trough javascript which I can kind of do for the console log. So my javascript outputs each date as individual item in browser console. I don’t know how to get that data back in bubble though.

The easier way would be to just use bubble to separate the list but I am blind to how to do this.

Here is the code I am using. So after choosing 2 dates and pressing a button bubble runs a javascript:

var startDate = new Date(“Date/TimePicker A’s value”);
var endDate = new Date(“Date/TimePicker B’s value”);

var getDateArray = function(start, end)
{
var arr = new Array();
var dt = new Date(start);
while (dt <= end)
{
arr.push(new Date(dt));
dt.setDate(dt.getDate() + 1);
}
return arr;
}

var dateArray = getDateArray(startDate, endDate);

//Output

dateArray.forEach(item =>
console.log(item));

console.log(dateArray);

bubble_fn_dates(dateArray);

For the list I then use an event that is fired after javascript ends and that event triggers JS2Bubble element which reads the bubble_fn_dates output. Then I create a new thing that is a list of dates, and from that I get the dates in a repeating group.

I later added forEach loop that separates items inside javascript and writes them to console log.
I tried bubble_fn_item(item); with create a new thing attached to javascript event and it creates a empty field in the database.

But before I even bother. Is there even a way to make multiple API calls from bubble without using shedule API? I am using the free version which does not support this.

When I get home I can post the link to the app so it is easier to see what I mean.

EDIT1: so here are the links:

Editor: https://bubble.io/page?type=page&name=playground&id=coinoscopy&tab=tabs-1

App: https://coinoscopy.bubbleapps.io/version-test/playground?debug_mode=true

Page TEST is not working. Playground does.

L

This is an interesting idea … the issue you’ll probably get is sending new values too fast for the page workflow to keep creating the new database rows. Try one at a time, and have the workflow create the record, then tell the javascript its ready for the next. Bubble will likely create the first five quickly, then rate limiting kicks in and each one takes 1.5 seconds.

Another option is the Data API to bulk create rows in one API call, they still take around 1.5 seconds each row though.

1 Like

Damn that is a lot of seconds :slight_smile:

So I have to consider the fact I will mostly call between 10 to 100 days… that is a lot if for each day the delay will be 1.5sec.

So I am stuck with javascript on this one. I will have to do the conversion to unix then make api calls to extrnal source and then use the values in chart. All o that inside javascript. Is that even possible while still using bubble. I will figure it out in time bit before I begin, I would like to know if that is even possible.

So it comes down to using bubble only as an interface tool. :frowning:

That’s a single bubble function, I think it can do the entire list at once. Otherwise its also easy to do in javascript to output a list of numbers.

This brings us to the question, which external source, what does it require, what processing on the dates do you want to do, and what chart are you wanting to construct? There might be simpler ways to get what you want.

So first I apologize… this topic started as a problem with list separation and it quickly got into bubble plugin waters. To be honest, without the toolbox plugin I would probably already be looking elsewhere for solutions.

I am already converting the whole list of dates that I get from javascript to Unix timestamps trough a repeating group. Extract,unix / 1000 …
You can check the link in my second post.

I also saw a plugin for that so that is not the issue.

The api I am calling is cryptocompare api. Point is I want to compare historical price and volume growth for different groups of crypto currencies. I want the user to be able to save a profile that contains x number of altcoins and then to choose date range to get prices for those dates. That is then an input for multiseries chart. Point is to be able to save a group of coins as a profile so the user would not have to choose that each time he starts the app.

As far as I know I have to call for:
Fsym - coin
Tsym - fiat to convert the price to
And timestamp of the day that I need the price for.
So I am thinking I need to call each timestamp (unix format) separately.
If I could do this with a list I would be golden.

for the charts I am looking at chart.js library. I already got it working with their example code inside bubble and with dynamic values with the help of toolbox plugin so I think I’ll manage that part. I read somewhere that you could use lists or arrays as inputs to chart.js so if only I could avoid the list separation and just call for the whole range/list.

(EDIT1:I am currently exploring other API functions that I somehow did not find before on cryptocompare so maybe there is a way to pass a list and get another list in return.)

Other charting solutions dont do it for me since they are either 1 or 2 series max or they are paid plugins which right now is not an option. Plus chart.js looks really good.

So I dont really see any other way but to have the dates from datearray to be individual items and also I will need the ability to make a large amount of api calls from bubble in sequence with no chance of a mistake since that would break the ehole chart…

Also it is my first week of “bubbling” of which most of my time was spent on learning basics of javascript to be able to use the toolbox. So maybe I am missing something that is already there.

Looks like the API will return a list of price and volume data over a date or time range with a single call, so there’s no need to generate a list of timestamps beforehand.

What to store in Bubble’s database? I suggest just store the information that is needed to remember the user’s choices, and reload the price data on each page visit. The graph interface is then simpler and faster.

Where to call the API from, Bubble or javascript? This depends on several aspects …

  • Calling from Bubble the call is initiated by the Bubble server, usually the same IP address for each call. The crypto API is rate limited by IP. If you have more than 20 users load the page in the same minute, assuming you only need one call per user, the rate limit will kick in.

  • Calling from javascript will use each user’s IP address for the rate limit, so the rate limit will be reached less often. This does mean more complex javascript, so the trade-off depends on how many customers your app has.

  • Calling from javascript also means your customers can look at the code and make the calls themselves, but this doesn’t seem to be a problem for your particular use case, as the data is already publicly available.

  • If you have any secrets in a call, like authorization tokens, you’ll need to make those from Bubble so as not to expose them to the public.

Good luck, sounds like a fun project. : )

1 Like