Sergih28 / groc

Grind for the vision, revamp for precision, organize with decision, complete the mission.
MIT License
3 stars 0 forks source link

Propose a json structure to save the pomodoro data (in localstorage) #66

Closed Sergih28 closed 10 months ago

Sergih28 commented 10 months ago

Keep in mind that you have to know when you start and finish in terms of datetimes, but you can have pauses in between.

Feel free to write the example with invented data to see the json structure.

ehdlg commented 10 months ago

Here is my proposal for the JSON structure:

The JSON contains a key with an array named "pomodoros". Each element in this array represents a pomodoro and is an object that includes:

The start and end time are represented as Unix timestamps, but these values can be altered.

Here's the JSON example:

{
  "pomodoros": [
    {
      "id": "unique_id_1",
      "startTime": 1636958400, 
      "endTime": 1636960500, 
      "pausedTime": [
        {
          "start": 1636958700, 
          "end": 1636959000 
        },
        {
          "start": 1636959300, 
          "end": 1636959600 
        }
      ]
    },
    {
      "id": "unique_id_2",
      "startTime": 1637045400,
      "endTime": 1637047500,
      "pausedTime": []
    }
  ]
}
Sergih28 commented 10 months ago

Looks good to me. Just some slight changes, I'd rename pausedTime to pausedTimeRanges so it's clearer what it contains.

And unique ids should be uuids.

@ehdlg Could you make that change please?

Also, create a file with that initial data, that we will use in the future to easily create data for the dev environment. Think what file name should be better for this It could be inside a data or fixtures folder, inside or outside src, I'm not sure, give it some thought.

ehdlg commented 10 months ago

Got it, here is the JSON with the changes that you proposed:

{
  "pomodoros": [
    {
      "id": unique_uuid,
      "startTime": 1636958400, 
      "endTime": 1636960500, 
      "pausedTimeRanges": [
        {
          "start": 1636958700, 
          "end": 1636959000 
        },
        {
          "start": 1636959300, 
          "end": 1636959600 
        }
      ]
    },
    {
      "id": unique_uuid,
      "startTime": 1637045400,
      "endTime": 1637047500,
      "pausedTimeRanges": []
    }
  ]
}

Regarding the file name and the location, I think 'pomodoroSampleData.json' could be a good name, and for the location, placing it in a designated 'data' folder within the 'src' directory offers a logical and organized structure.