Retrieve all data from firebase

Hi I have made a game with app inventor called mathematics .

If someone makes high score, that score stores in firebase all ok , tag=players name and value his name& score … as image below
But I want to retrieve all values from database in a listview to show all players with highscore .How can I manage that?


fire

Set ProjectBucket at correct level (Mathematicks)
Get TagList (sakis, navoc, etc)
Iterate over the taglist to select name and score for each entry
Display

The “better” method is to create another “bucket” when data is uploaded containing just the names and scores. Then you can call all that back using firebase rules to do the ordering and some parameters using the web component.

Thank you for your answer.
I did store them in different way .
But how can I retrieve all tags and values in a list to show all highscored players
3rd image no value retrieve


fire2

To use Firebase rules to order your scores is beyond the capabilities of the built-in Firebase blocks in AI2.

You need to use the web component to call your subset of data > scores: Name: “score”, Name: “score”
and set rules in Firebase to order your data:

{
  "rules": {
    ".read": true,
    ".write": true,
    "scores": {
      ".indexOn": [".value"]
    }
  }
} 

As I mentioned you will need a subset of data saved to firebase for this to work.

Under your main project bucket you need a child called “scores”, then you save to this the player name and their score (at the same time as you save then to the mathematiks child) so that you end up with:

scores
   2 test: 400
   3 test: 200
   4 test: 500

You then use a GET request in AI2 web component to call back the data in scores

this example returns the top 50 scores, with highest first.

The other way is to call back all your data in mathematiks and work through the list/s generated and orgnaising and sorting to get your leaderboard

Thanks my friend
Now I have data but not in good appearance

Store3
fire3
json3

Unfortunately, firebase does not return the ordered results sorted! (Odd, because it does all the work in getting the top scores…)

Try something like these blocks:

You need the list sorting extension from Hossien Amerkashi

The blocks should load your leaderboard to one label

If your score numbers go up over 99 you will also need to set leading zeros to your score numbers in order to allow sorting

hi

first time i see this way to retrieve data from firebase can i use it even i don’t want to order data ?

regards

Yes, see the Web REST api page for Firebase

https://firebase.google.com/docs/reference/rest/database

Be aware that the REST / web component method handles/presents data slightly differently

Also see:

for more detailed use of the Web REST methods available

I manage to get firebase data with the easy way (not beautiful) but I can not make it order by highscore (value) . Any idea ?

firebase4

rules4

As I said above, you need to pull the returned data into a list, swap the name and the number around, so instead of andreas,15 you have 15,andreas, then apply leading zeros to each number so that you can sort: 0015,andreas; 0018,pitis etc.

Something I don’t make well

Set your label to HTMLFormat

Ok Now … how can I make an order by score decenting
first 19 points willy 2nd pitis 18 etc

For the third time…
You need to set the numbers with leading zeros
Do this when you swap the name and number around.
For your current numbers you need 3 digits, if scores will go into the hundreds then you need 4 digits

Should look like this when you are done:

Lederboard

019 : willy
018 : pitis
016 : tasos
015 : andreas
010 : sakis
001 : hammer

Thank you Very Much .
All done !!!

I was able to implement this solution to read my data
thanks to the block look in pair list

but I still have a problem when it comes to retrieving the list
i use the same way the key liste but i don’t understand why list are this way [John,Julia]
when i check with is a list? thing i get false

i need a serious glance at my problem

regard

I think something triggers from the app and delete all the data from firebase.
One time happened when updated the app , and other time I did not understand .
Is there any rule to auto delete firebase values ?
I create new firebase with new email user but it happened again

Ok I found it , it was if the nickname textbox was empty deleted all values , now I create “if is empty write Anonymus” and all is Ok.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.