Changes

no edit summary
Line 24: Line 24:     
Each journal object will contain an array for spent times, for each time the entry was launch. This created a 1-to-1 relation between spent times and the current launches times. This way, the entry metadata can reflect not only "when" but also "for how long".
 
Each journal object will contain an array for spent times, for each time the entry was launch. This created a 1-to-1 relation between spent times and the current launches times. This way, the entry metadata can reflect not only "when" but also "for how long".
  −
== How to access this metadata ==
  −
  −
from sugar3.datastore import datastore
  −
  −
entries, count = datastore.find(self._query())
  −
for entry in entries:
  −
    raw_data = entry.metadata.get('spent-times', None)
  −
  −
    if raw_data is not None:
  −
        spent_times = map(int, raw_data.split(', '))
      
== Benefit to Sugar ==
 
== Benefit to Sugar ==
Line 44: Line 33:  
This feature is already implemented and working on Australian au1c images. The implementation requires a small modification to sugar-toolkit and sugar-toolkit-gtk3 [https://github.com/tchx84/sugar-toolkit-gtk3-1/commits/spent-time-3 see initial implementation].
 
This feature is already implemented and working on Australian au1c images. The implementation requires a small modification to sugar-toolkit and sugar-toolkit-gtk3 [https://github.com/tchx84/sugar-toolkit-gtk3-1/commits/spent-time-3 see initial implementation].
   −
The change consist in modifying the base Activity class, using the launch time timestamp in conjuction with "set_active" and "save" methods, to calculate and accumulate the seconds for when the activity was "active". The spent time is stored as an array of accumulated seconds, each for each time the entry was launched. The new metadata array is called "spent_times".
+
The change consist in modifying the base Activity class, using the launch time timestamp in conjuction with "set_active" and "save" methods, to calculate and accumulate the seconds for when the activity was "active". The spent time is stored as a string of comma separated integers, each for each time the entry was launched. The new metadata array is called "spent_times".
    
The scope of this feature is the time accumulation and metadata storage.
 
The scope of this feature is the time accumulation and metadata storage.
    +
== How to access this metadata ==
 +
 +
from sugar3.datastore import datastore
 +
 +
entries, count = datastore.find(self._query())
 +
for entry in entries:
 +
    raw_data = entry.metadata.get('spent-times', None)
 +
 +
    if raw_data is not None:
 +
        spent_times = map(int, raw_data.split(', '))
 
== User Experience ==
 
== User Experience ==
 
The user experienced is untouched.
 
The user experienced is untouched.
572

edits