KL13NT / loggy

Gain insights on the time you spend online!
GNU General Public License v3.0
9 stars 0 forks source link

Refactor the data schema #13

Open KL13NT opened 3 years ago

KL13NT commented 3 years ago

The current schema is difficult to maintain and use, and forces me to build mumbo jumbo code that is confusing and poor in performance. It's also difficult to get started with since it's difficult to document for onboarding.

The current schema is:

class Entry {
  origin: string;
  lastVisit: Date;
  firstVisit: Date;
  [year]: {
    [month]: {
      [day]: number
    }
  }
}

This schema is not properly built, doesn't adhere to any SOLID principles, difficult to maintain, and is difficult to maintain. The new schema is:

class Session {
  date: Date;
  duration: number;
}

class Entry {
  origin: string;
  lastVisit: Date;
  firstVisit: Date;
  sessions: Array<Session>;
}

This will require an overhaul of the codebase to use the new schema.

KL13NT commented 3 years ago

IDEA: Don't transform the datastore itself. Transform the representation by adding an abstraction layer that translates the datastore format into an application format, like an ODM.

KL13NT commented 3 years ago

This proves useless against the current data though. We're still in pre-v1.0.0, so it should be okay to nuke it all.