Skip to content
This repository has been archived by the owner. It is now read-only.

Database Design

Kohei Yoshino edited this page May 4, 2015 · 1 revision

The design of the new BzDeck key-value store (IndexedDB) that supports multiple accounts and sync.

Global DB

  • DB name: global
  • Object stores: bugzilla, accounts

bugzilla

[Version 1]

  • The config can be found at /bzapi/configuration. Not yet available in the native REST API.
  • URLs including API endpoints are subject to change, so those should not be saved, rather be in the code.
[
  {
    'host': 'mozilla',
    'config': { ... },  // Needs refresh (when?)
  },
  {
    'host': 'mozilla-dev',
    'config': { ... },  // Needs refresh (when?)
  },
]

accounts

[Version 1]

  • The name (email address) can be used with multiple Bugzilla instances so it's not unique. A host+name combination should be unique.
  • The key will be auto increment (use the autoIncrement flag).
[
  {
    'host': 'mozilla',
    'name': 'kohei.yoshino@gmail.com',  // NOT unique
    'token': '123456-mtvGu2ngDs',  // Provided by user or Bugzilla
    'active': true,  // Signed-in
  },
  {
    'host': 'mozilla-dev',
    'name': 'kohei.yoshino@gmail.com',  // NOT unique
    'token': '789012-LfzS4F2RPk',  // Provided by user or Bugzilla
  },
]

Per-account DB

  • DB name: host ID and user name, e.g. mozilla::kohei.yoshino@gmail.com
  • Object stores: bugs, users, prefs
  • This will be BzDeck.model.db.account in JS

bugs

[Version 1]

  • The content of bugs can be different depending on user's privilege. That's why bugs belong to each account, not to the instance.
  • Annotations are prefixed with _ and subject to sync.
[
  {
    'id': 952880, // inline key
    'summary': 'Deploy production change notification system',
    ...
    '_tags': new Set(['compatibility', 'gaia']),
    '_starred': true, // Previously this was the Set-typed _starred_comments property
    '_unread': false,
    '_last_viewed_time': 1396191070393,  // Used to mark unread comments
  },
]

subscriptions

[Version 2, proposal]

  • Previously a star was an annotation of each bug. Version 2 makes it a subscription type so we can manage tags and saved searches in the same way. This change removes the capability of adding a star to each comment.
  • In the future, we can hopefully remove this local dataset and sync the subscription list between multiple devices using the Bugzilla API, if the API allows to update the user's saved search list. Currently it's a read-only list provided by the user method.
[
  {
    'id': 1, // inline key
    'type': 'star', // The star-typed subscription cannot be removed by the user
    // 'label': 'Star', // The label is defined and later localized in the code
  },
  {
    'id': 1429739599732, // Date.now()
    'type': 'tag', // A tag is an ID-based, user-defined subscription similar to the Star subscription
    'label': 'Site Compatibility',
  },
  {
    'id': 1429740096551, // Date.now()
    'type': 'search', // A saved search is query-based subscription
    'label': 'Site Compatibility bugs',
    'query': new Map([['product', 'core'], ['keywords', 'site-compat']]),
  },
]

users

[Version 1]

  • Annotations are prefixed with _ and subject to sync.
[
  {
    'id': 232883,  // Inline key
    'name': 'kohei.yoshino@gmail.com',  // Unique but the email address can be altered
    'real_name': 'Kohei Yoshino [:kohei]',  // Needs refresh (when?)
    '_image': 'data:image/png;base64,iVBORw0KGgoAAAANSU ...',  // Provided by Gravatar, cached as a base64 string (or blob) for offline use, needs refresh (when?)
    '_starred': true, // For Address Book
  },
]

prefs

[Version 1]

  • Users may want to have different preferences per account, depending on how they are working with that Bugzilla instance.
  • This object store will be subject to sync.
[
  {
    'name': 'ui.home.layout',  // Inline key
    'value': 'vertical',
  },
  {
    'name': 'ui.theme.selected',  // Inline key
    'value': 'Light',
  },
  ...
]
You can’t perform that action at this time.