Delay in obtaining the largest number

On this occasion I try to obtain the largest number from a list of numbers on FB, that is, 1079.
and then increase 1 and thus continue with the correlative

this is for an order counter

image

when I run it in MITAI2Companion I get it immediately (OK)
Companion

When I run it in Emulator and also in Windows Subsystem it delays (DELAY)
Subsistema de Windows

I wanted to put a conditional "if it contains a number" to go to the next step

but count and keep running until you find the eldest

Or if there is another method, I would appreciate it. The idea is to have a correlative.

Bloks

the call from: A2 to obtain the data is when starting screen and it still takes a while

There is the possibility of obtaining the last number saved by time so as not to be looking for the largest?

image

If you don't mind skipping numbers, why not use Clock1.SystemTime for a unique identifier?

I had another look. You should using Firebase indexing and a Firebase query to return the largest value, get Firebase to do all the work for you. Firebase also has an increment function that you can call to add the next number.

do you have an example?

I was analyzing the topic and there is no need to save all the correlatives alone:
the last saved
and the number that should start
image

but it still takes a while to get it
image

posd.
I am using Windows Subsystem for Android

This means that I have it installed on my Windows 11 PC.
on mobile everything is fine

Blocks

image

Rules

image

Data

image

output

image

(This is working with a firebase array...)

1 Like

image
It doesn't allow me to change the name

I must be doing something wrong

image

There is no project bucket called rules. You will need to set one.

e.g.

{
  "rules" : {
     "getMax": {
        ".read": true,
        ".write": true,
        ".indexOn": ".value"
     }
  }
}

image

image

The label that should be 1 comes out "null"

and you are getting a list, not a json, like I did.

Go into the firebase console, and remove all the quotes from your values. What happens then ?

and make sure they are all set as numbers (123)

image

Also, if you persist with using firebase arrays, you should read all of this:

and if I can wean you off using the firebase component, to use just the web component instead...

hmmm, just tested by storing values using the firebase component:

image

ran the query and got back

{"2":"3456"}

so what I suggest up above is not the issue. How are you getting that list ? What happens if you just call all the data in getMax back ?

image

null,"1509"

Do you get the same on your mobile (real device) ? (let us try to rule out this windows subsystem Android thing)

I haven't tried it yet in the Windows subsystem
this happens to me on my mobile

I am a bit lost as to what is happening here.

If you wish, share your firebaseurl / aia in a PM to me, so I can see if it is a firebase or device issue.

I already found the problem
Only allows 5 items minimum
if there are only 4 it returns null
try it

shouldn't

image
ok

image
null

There is no doubt that the web component is much faster than the FB when working with the Windows subsystem
The question is why it allows the search for the largest with only 5 items
and not with only 2

Well found.

It is because it is a "fake" Firebase Array, and Firebase is confused.

If you do this

image

the query works OK, even if you only have one value in there.

If you use a real Firebase array, then the query still works, but returns the value in square brackets for items 0,1,2, then after that {"2":1555} format.

The best way to do this, in my opinion, is to post values, then you get a time based alpha-numeric key for each value

image

I wrote a small extension that generates these "push IDs", so if you want to upload a list of values to firebase, you can use this and then use a PATCH command to add the whole lot to your node.

image

perfect
if you wanted to get only 2222 without trimming.
how could i do it

it's not a list