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 firebase backend #33

Closed
skamansam opened this issue Jun 20, 2020 · 1 comment · Fixed by #47
Closed

Add firebase backend #33

skamansam opened this issue Jun 20, 2020 · 1 comment · Fixed by #47
Assignees
Labels
DevOps DevOps Tasks

Comments

@skamansam
Copy link
Member

skamansam commented Jun 20, 2020

We need to start using the firebase store. From now on, we will have to think about how to store the data constructs used. We should be using the realtime database. We will need to implement our own offline solution.

We need to organize data for queries, not for storage. As with any NoSQL database, denormalization is key. Please read completely through the firebase documentation before continuing.

Here is the scheme I have in mind:

NOTE: The top-level items are Collections. The *ref* items are the document references.

{
  states: {
    stateRef1: {
      name: 'CheckBoxes with an Intermediate State',
      description: 'Standard checkboxes with an intermediate state.',
      stateOrder: ['notDone', 'inProgress', 'done'],
      states: {
        notDone: {
          text: 'Not Done',
          value: 0,
          icon: 'mdi-checkbox-blank-outline',
          color: '#ff0000',
        },
        done: {
          text: 'Done',
          value: 1,
          icon: 'mdi-checkbox-marked-outline',
          color: '#00ff00',
        },
        inProgress: {
          text: 'In Progress',
          value: 0.5,
          icon: 'mdi-checkbox-intermediate',
          color: '#00ffff',
        },
      },
    },
  },
  userStatuses: {
    user1Ref: {
      listRef: {
        _status: 'inProgress', // cached status so we don't have to actually get the list items to calculate its status. useful for sublists
        listItemRef: 'done',
        listItem2Ref: 'inProgress',
      },
    },
  },
  lists: { // we want to store the list options here, so we don't have to retrieve the entire list with items when we just want a sublist
    list1Ref: { // firebase assigns new docs these IDs, when using push() we should take full advantage of this.
      title: 'Test One',
      color: '#ff00ff', // the color of the tile and background color of the page view
      states: 'stateref1', // we are deduplicating states by
      prerequisite: 'list3Ref.complete && list5Ref.listItem1Ref1 >= 5', // prerequisites for enabling this list. NO EVAL()!
    },
    list2Ref: {
      title: 'Test Two',
      color: '#ff0000',
    },
    list3Ref: {
      title: 'Test Three',
      color: '#ffff00',
    },
    list4Ref: {
      title: 'Test Four',
      color: '#465362',
    },
  },
  listItems: {
    list1Ref: {
      list1Item1Ref: {
        text: 'Item 1', // the  dispalyed text of the list item
        state: 'done', // state can be any arbitrary value, i.e. "5", "ten",
        prerequisite: '(list item 2 title).done', // one of several ways to specify objects in our
        order: 0,
      },
      list1Item2Ref: {
        text: 'Item 2',
        state: 'inProgress',
        order: 1,
      },
      list1Item3Ref: {
        ref: 'someOtherListID',
        order: 2,
      },
    },
    list2ref: {
      list2Item1Ref: {
        text: 'Item 2',
        state: 'inProgress',
        order: 0,
      },
      list2Item2Ref: {
        text: 'Item 2',
        state: 'inProgress',
        order: 1,
      },
    },
  },
}

NOTE: list.bgColor is now just color.
You should use the firebase emulator for testing this feature. https://firebase.google.com/docs/emulator-suite

@skamansam skamansam changed the title WIP: Add firebase backend Add firebase backend Jun 21, 2020
@skamansam skamansam added the DevOps DevOps Tasks label Jun 21, 2020
@skamansam skamansam added this to To do in Welcome to Questlists via automation Jun 21, 2020
@skamansam skamansam added this to the Initial Release milestone Jun 21, 2020
@KickButtowski80 KickButtowski80 self-assigned this Jun 22, 2020
@skamansam skamansam moved this from To do to In progress in Welcome to Questlists Jun 26, 2020
@skamansam
Copy link
Member Author

skamansam commented Jul 26, 2020

Note: this comment isn't complete yet.

After much information consumption, I have devised a new DB schema. Since firecloud charged based on document reads, and can't return partial documents, I have optimized for views and documents/size.

Note: there is a 1Mb document limit, so some objects may require multiple documents. We will implement that when we get there.

Collections:
  globalPreferences. // Defaults and global configuration options
  lists  // the list objects
  lists/{list.id}/listItems. //the listItems for the list. One document is an array of all the items.
  stateGroups // a group of states
  users. // User information
  users/{user.id}/listItemStates // one document for all the states.

@skamansam skamansam linked a pull request Aug 4, 2020 that will close this issue
@skamansam skamansam moved this from In progress to Review in progress in Welcome to Questlists Aug 11, 2020
Welcome to Questlists automation moved this from Review in progress to Done Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DevOps DevOps Tasks
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants