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

Add spent-times to metadata #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/sugar3/activity/activity.py
Expand Up @@ -753,6 +753,16 @@ def save(self):
self.metadata['buddies_id'] = json.dumps(buddies_dict.keys())
self.metadata['buddies'] = json.dumps(self._get_buddies())

def get_last_launch():
return int(self.metadata['launch-times'].split(', ')[-1])

spent_time = int(time.time()) - get_last_launch()

if 'spent-times' in self.metadata:
self.metadata['spent-times'] += ', %d' % spent_time
else:
self.metadata['spent-times'] = str(spent_time)

preview = self.get_preview()
if preview is not None:
self.metadata['preview'] = dbus.ByteArray(preview)
Expand Down