Suggested changes to the trophy data format

Bug #670185 reported by Stuart Langridge
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cheers
In Progress
Medium
Cheers

Bug Description

At the moment, the trophy data looks like this:
{
    "id":"sil-testing-trophy",
    "setname":"Testing",
    "seticon": "",
    "app":"application://banshee.desktop",
    "appname":"Banshee Music Player",
    "title":"Stuart's Testing Trophy",
    "iconpath":"",
    "priority": 1,
    "unlocked": "False",
    "stockicon":"",
    "desc": {
        "1": {
            "lang":"en-us",
            "desc": "Listen to Music alot"
        },
        "2": {
            "lang":"en-uk",
            "desc": "Listen to Music a lot, a lot"
        }
    }
}

This is pretty cool. Having looked at it a bit, I have a couple of suggestions for the format:

{
    "id":"sil-testing-trophy",
    "setname":"Testing",
    "seticon": "",
    "app":"application://banshee.desktop",
    // remove appname
    "title":"Stuart's Testing Trophy",
    // make iconpath be an attachment
    // remove priority
    // remove unlocked
    "stockicon":"",
    "desc": {
        "default": { // add default key
            "desc": "Listen to Music alot"
        },
        "en-us": { // make lang the key
            "desc": "Listen to Music alot"
        },
        "en-uk": {
            "desc": "Listen to Music a lot, a lot"
        }
    }
}

Some notes on what the suggested changes actually mean:

    // remove appname
It's probably best to look up the appname from the .desktop file when you need it, because then you'll get translated names, and because if the app changes its name you won't know
    // make iconpath be an attachment
If you're storing data in desktopcouch, then a good way to store the icon for the trophy (if it's not a stock icon) is as an attachment to the desktopcouch record; that way, the icon follows the rest of the data around between machines and to websites and so on
    // remove priority
I, personally, would suggest that all trophies are of the same priority as far as notify-osd is concerned. Things like a trophy award aren't really of critical priority; critical priority is for things like "your laptop will shut down in 30 seconds" :-)
    // remove unlocked
Ideally you wouldn't need "unlocked" because that question is really "is there an award record for this person for this trophy", which is really quick to ask
    // make lang the key
There may be a reason I haven't seen, but it might be best to use the language as the key to the desc dictionary; that way, finding a description for a language is quick (if you have numbers as the keys then to find the desc for "en-uk" you have to iterate through the whole dictionary until you find it)
    // add default key
Of course, you'll want a default desc for where there isn't a translation for your language

Just suggestions, but I quite like cheers so I thought I'd give you my thoughts.

Revision history for this message
Seif Lotfy (seif) wrote : Re: [Bug 670185] [NEW] Suggested changes to the trophy data format
Download full text (6.1 KiB)

On Wed, Nov 3, 2010 at 1:30 AM, Stuart Langridge <
<email address hidden>> wrote:

> Public bug reported:
>
> At the moment, the trophy data looks like this:
> {
> "id":"sil-testing-trophy",
> "setname":"Testing",
> "seticon": "",
> "app":"application://banshee.desktop",
> "appname":"Banshee Music Player",
> "title":"Stuart's Testing Trophy",
> "iconpath":"",
> "priority": 1,
> "unlocked": "False",
> "stockicon":"",
> "desc": {
> "1": {
> "lang":"en-us",
> "desc": "Listen to Music alot"
> },
> "2": {
> "lang":"en-uk",
> "desc": "Listen to Music a lot, a lot"
> }
> }
> }
>
> This is pretty cool. Having looked at it a bit, I have a couple of
> suggestions for the format:
>
> {
> "id":"sil-testing-trophy",
> "setname":"Testing",
> "seticon": "",
> "app":"application://banshee.desktop",
> // remove appname
> "title":"Stuart's Testing Trophy",
> // make iconpath be an attachment
> // remove priority
> // remove unlocked
> "stockicon":"",
> "desc": {
> "default": { // add default key
> "desc": "Listen to Music alot"
> },
> "en-us": { // make lang the key
> "desc": "Listen to Music alot"
> },
> "en-uk": {
> "desc": "Listen to Music a lot, a lot"
> }
> }
> }
>
> Some notes on what the suggested changes actually mean:
>
> // remove appname
> It's probably best to look up the appname from the .desktop file when you
> need it, because then you'll get translated names, and because if the app
> changes its name you won't know
> // make iconpath be an attachment
> If you're storing data in desktopcouch, then a good way to store the icon
> for the trophy (if it's not a stock icon) is as an attachment to the
> desktopcouch record; that way, the icon follows the rest of the data around
> between machines and to websites and so on
> // remove priority
> I, personally, would suggest that all trophies are of the same priority as
> far as notify-osd is concerned. Things like a trophy award aren't really of
> critical priority; critical priority is for things like "your laptop will
> shut down in 30 seconds" :-)
> // remove unlocked
> Ideally you wouldn't need "unlocked" because that question is really "is
> there an award record for this person for this trophy", which is really
> quick to ask
> // make lang the key
> There may be a reason I haven't seen, but it might be best to use the
> language as the key to the desc dictionary; that way, finding a description
> for a language is quick (if you have numbers as the keys then to find the
> desc for "en-uk" you have to iterate through the whole dictionary until you
> find it)
> // add default key
> Of course, you'll want a default desc for where there isn't a translation
> for your language
>
> Just suggestions, but I quite like cheers so I thought I'd give you my
> thoughts.
>
> ** Affects: cheers
> Importance: Undecided
> Status: New
>
> --
> Suggested changes to the trophy data format
> https://bugs.launchpad.net/bugs/670185
> You received this bug notificatio...

Read more...

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

Hi everyone,

Here are my thoughts:

  // Appname
I knew that using xdg APIs it is possible, but still I don't know how to use them. I will surely try it out and fix cheers for it
STATUS: To be fixed

// Priority
We can, No harm would be done. Probably some kittens would be dead, but overall fine suggestion.
STATUS: To be Fixed

// Add default key
I thought that if nothing is present, then en-us can be taken. Let's not rely on that.
STATUS: To be Fixed

// Iconpath
Right now it is using sqlite which is somewhat a pain since I have to do all the SQL queries and forming the trophy instance for DBus etc. I hope desktopcouch API would be simpler. Will fix it
STATUS: To be fixed

// Remove Unlocked
Actually the workflow is: The apps register their trophies. By default the status is unlocked/unawarded. An application can then award the trophy. You can even show to the user that these trophies are still unawarded. What can be done to get it unlocked.
STATUS: To be discussed.

I think after the "Remove Unlocked" has been sorted out. I can start implementing.

Revision history for this message
Stuart Langridge (sil) wrote :

After useful discussion, the proposal is now as follows:

There are two types of records: set and trophy. Award records are not required.

A set record looks like this:
{
  "id": "my-great-trophy-set", // this is a couchdb ID, so no spaces or weird characters; it is not user-displayed
  "name": {
"My Trophy Set"
}
and has an attachment "icon", which is a PNG of the set's icon.

A trophy record looks like this:
{
  "id": "some-id-for-trophy", // this is a couchdb ID, so no spaces or weird characters; it is not user-displayed

Revision history for this message
Stuart Langridge (sil) wrote :

(ignore comment #3, I hit enter too early)

After useful discussion, the proposal is now as follows:

There are two types of records: set and trophy. Award records are not required.

A set record looks like this:
{
  "record_type": "http://cheersproject.example.org/records/trophyset",
  "id": "my-great-trophy-set", // this is a couchdb ID, so no spaces or weird characters; it is not user-displayed
  "stockicon": "gtk-info", // the stockid of an stock icon for this trophy; optional
  "name": {
    "default": "My Trophy Set",
    "en-us": "My Trophy Set",
    "fr-fr": "Mon Set de Trophie"
  }
}
and has an attachment "icon", which is a PNG of the set's icon.

A trophy record looks like this:
{
  "record_type": "http://cheersproject.example.org/records/trophy",
  "id": "some-id-for-trophy", // this is a couchdb ID, so no spaces or weird characters; it is not user-displayed
  "trophyset": "my-great-trophy-set",
  "stockicon": "gtk-info", // the stockid of an stock icon for this trophy; optional
  "application": "application://banshee.desktop",
  "title": {
    "default": "My Great Trophy",
    "fr-fr": "Mon Trophie a la Magnifique"
  },
  "description": {
    "default": "You must be really great! That's why you've got this trophy.",
    "fr-fr": "Vous êtes tres magnifique!"
  },
  "private_application_annotations": {
    "cheers": {
      "awarded": true,
      "awarded_timestamp": "2010-11-03T16:27:10+00:00"
    }
  }
}
and an attachment "icon", which is a PNG of the set's icon.

If a trophy doesn't have an "icon" attachment, use its "stockicon" key to get a Gtk stock icon for the trophy. If a trophy has neither, get its trophyset and use the trophyset's icon attachment. If the trophyset doesn't have an icon attachment, use the trophyset's stockicon. If the trophyset has neither, then use the default trophy icon, which is built into cheers.

Trophies that have not yet been awarded to this user either have private_application_annotations.cheers.awarded = False, or that key is not present at all. (When a trophy is first created, don't bother creating the private_application_annotations; if a trophy is awarded then unawarded, set private_application_annotations.cheers.awarded = False.) When a trophy is awarded to this user, set private_application_annotations.cheers.awarded = True, and set private_application_annotations.cheers.awarded_timestamp to the current ISO timestamp.

Revision history for this message
Stuart Langridge (sil) wrote :

grr. Of course, the icon attachment on a trophy record is the trophy's icon, not the set's icon. Typo.

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

Everything sorted out. Will start implementing sooner.

Changed in cheers:
assignee: nobody → Manish Sinha (manishsinha)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

Adding more info. As per Stuart

record_type:
every record in desktopcouch has a record type. It's a way of knowing that all trophy records are the same type. It must be a URI, but that URI doesn't have to actually point to a valid page. It's quite useful if there's a description of the record schema at that page, but it's not compulsory

Revision history for this message
Seif Lotfy (seif) wrote :

What happens if I try to register a trophy with a set that is non existant?

Revision history for this message
Seif Lotfy (seif) wrote :

Also I think a set needs a description to explain what its trophies are all about

Changed in cheers:
assignee: Manish Sinha (manishsinha) → Cheers (cheers)
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.