Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSON output #15

Closed
larsenv opened this issue Aug 6, 2022 · 7 comments
Closed

Fix JSON output #15

larsenv opened this issue Aug 6, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@larsenv
Copy link
Contributor

larsenv commented Aug 6, 2022

https://github.com/RiiConnect24/RiiTag-RPC relies on getting a JSON file formatted in the format used with RiiTag v1 in order to read what games are being played. Since RiiTag v2 doesn't output this properly, RiiTag-RPC is currently broken. I think it might be only checking the games played and the timestamp.

Example JSON https://transfer.archivete.am/Pk8XE/314466499312222208.json

Brawl345 added a commit that referenced this issue Aug 7, 2022
Don't know what fields are needed exactly
@Brawl345
Copy link
Collaborator

Brawl345 commented Aug 8, 2022

Looks like it expects a dictionary: https://github.com/RiiConnect24/RiiTag-RPC/blob/master/riitag/user.py#L15 not an array what we currently have/what's in your JSON. Maybe @DismissedGuy can say something about this?

@Brawl345 Brawl345 added bug Something isn't working needs more info More info needed labels Aug 8, 2022
@malmeloo
Copy link
Contributor

malmeloo commented Aug 8, 2022

Larsen's example JSON is an example of V1's internal "database" and does not follow the same format as the public JSON API. This is where V1 generated its response: https://github.com/RiiConnect24/RiiTag/blob/b83c9bd3a1152df7eb22876dec60f5b643584e5a/app.js#L472

It's been way too long since I've touched RiiTag-RPC, but IIRC, it should expect the following format:

{
  "user": {
    "name": <name on riitag>,
    "id": <user id>
  },
  "tag_url": {
    "normal": <url to regularly sized tag>,
    "max": <url to max resolution tag>
  },
  "game_data": {
    "last_played": {
      "game_id": <game id>,
      "console": <console>,
      "region": <game region>,
      "cover_url": <url to game cover>,
      "time": <time of last launch as unix epoch>
    },
    "games": [ <chronologically ordered list of recently played game IDs> ]
  }
}

game_data.last_played can also be an empty dict if the user hasn't played any games yet.

It's worth noting that I haven't had time yet to actually check the error myself, but following the above format should in theory fix it.

@Brawl345 Brawl345 removed the needs more info More info needed label Aug 8, 2022
@Brawl345
Copy link
Collaborator

Brawl345 commented Aug 8, 2022

Thank you, I think I can work with this! I think some fields are unused (region? is the games array even used?) and I would like to reorganize them (making games not an array of ids but an array of dicts)

@malmeloo
Copy link
Contributor

malmeloo commented Aug 8, 2022

Some fields are indeed unused; which ones exactly I cannot tell right now but I'll look into it. I do know that the games array is used to display a simple list of games the user has played in the past.

I do agree that the current format isn't the best. Feel free to change it around, I can update RiiTag-RPC to support the new format. Maybe even introduce some new features if the endpoint returns more interesting data to work with.

In any case, I won't be able to actually work on it until the end of the week, probably. So if a "quick fix" is required, it might be better to temporarily use that old format until then. Unless someone else feels like working on it of course.

@Brawl345
Copy link
Collaborator

Brawl345 commented Aug 9, 2022

The API should have the same output as the original one now:

JSON Output
{
   "user":{
      "name":"Brawl",
      "id":"110806999020625920"
   },
   "tag_url":{
      "normal":"http://localhost:3000/110806999020625920/tag.png",
      "max":"http://localhost:3000/110806999020625920/tag.max.png"
   },
   "game_data":{
      "last_played":{
         "game_id":"RSBJ01",
         "console":"wii",
         "region":"JA",
         "cover_url":"http://localhost:3000/api/cover/wii/RSBJ01",
         "time":1660063539985
      },
      "games":[
         "wii-RSBJ01"
      ]
   }
}

I will make a new endpoint (like /api/user/v2 or something) that returns new data with improved structure.

@malmeloo
Copy link
Contributor

Looks good, but RiiTag-RPC wants the last played epoch in seconds instead of milliseconds. I made a PR to fix that: #18

@malmeloo
Copy link
Contributor

By the way, I dug into the source code a bit, and the only data that it currently needs is the time of the last played game, the ID of that game, and the game history. All other fields appear to be unused as far as I can tell.

matthe815 added a commit to matthe815/LinkTag-Next that referenced this issue Jan 28, 2024
* refactor: Began merging sql requests and grouping private keys

* refactor: User page SQL code refactor and multi-game support

* refactor: User edit page SQL optimized

* refactor: Optimized SQL for edit page
matthe815 added a commit to matthe815/LinkTag-Next that referenced this issue Jan 28, 2024
* Feature: Moderation (RiiConnect24#9) (RiiConnect24#10)

* feature: Added banning, and, forced hidden button

* feature: Added hiding and shadow hiding users

* feature: Added badges to user profile

* feature: Added hiding from the front page when hidden

* fix: Fixed code related to front page hiding

* feature: Added game leaderboard - showing the #1 for all games

* refactor: Rewrote most of the game leaderboard code

* Rebase: Master -> Game Leaderboards (RiiConnect24#16)

* Feature: Moderation (RiiConnect24#9)

* feature: Added banning, and, forced hidden button

* feature: Added hiding and shadow hiding users

* feature: Added badges to user profile

* feature: Added hiding from the front page when hidden

* fix: Fixed code related to front page hiding

* Feature: Full-Site Multilanguage support (RiiConnect24#13)

* Feature: Moderation (RiiConnect24#9) (RiiConnect24#12)

* feature: Added banning, and, forced hidden button

* feature: Added hiding and shadow hiding users

* feature: Added badges to user profile

* feature: Added hiding from the front page when hidden

* fix: Fixed code related to front page hiding

* feature: Began adding the framework for multi-language support

* feature: Full localization support and all pages and nav bars

* Refactor: SQL optimization (RiiConnect24#15)

* refactor: Began merging sql requests and grouping private keys

* refactor: User page SQL code refactor and multi-game support

* refactor: User edit page SQL optimized

* refactor: Optimized SQL for edit page

* feature: Added clicking to go to profile and localizations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants