Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 37 Next »


{
  "config": { // All clients listen here permanently
    "articleBaseUrl": "http://cloud-storage.com/articles/"
  },
  "users": {
    "user_id_01": { // Clients listen here permanently
      "username": "user", // [default:null]
      "email": "user@somewhere.com", // [default:null]
      "fitnessLevel": 10, // [default:10]
      "fitnessBias": 1, // [default:1]
      "created": 987654345, // Unix timestamp (seconds) [default:0]
      "maxImpactCredit": 3, // [default:0]
      "impactCredit": 0.9, // [default:0]
      "updatedIC": 987654345, // Unix timestamp (seconds) [default:0]
      "triggersFired": { "triggerId_01": true, "triggerId_02": true }, // [default:null]
      "sessions": {
        "for7MW": 2, // [default:0]
        "forAfterburner": 0 // [default:0]
      },
      "totalActivities": 2, // [default:0]
      "totalActivities7MW": 1, // [default:0]
      "totalActivitiesAF": 1, // [default:0]
      "firstActivity7MW": 987654345, // Unix timestamp (seconds) [default:0]
      "firstActivityAF": 987654345 // Unix timestamp (seconds) [default:0]
    }
  },
  "visibleWorkoutDefs": { // Workout defs that are visible to the user
    "user_id_01": { 
      "for7MW": { // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "wktdef1": {
          "recommended": "", // Not recommended, just visible // [default:null]
	      "locked": true, // Not available to user (unlocked via IAP and/or journey trigger) [default:false]
		  "lockString": "Finish 6 more workouts before Thurs 9th June", // Displayed to user [default:null]
          "MWI": 0.54, // [default:0.5]
          "breakdown": {
            "epoc": 0.1, // [default:0.25]
            "cardio": 0.1, // [default:0.25]
            "metabolic": 0.1, // [default:0.25]
            "strength": 0.1 // [default:0.25]
          }
        },
        "wktdef2": {
          "recommended": "You need to work on your abs", // Recommended and reason for this to be shown to user
		  "locked": false, // Available to user
		  "lockString": "",
          "MWI": 0.54,
          "breakdown": {
            "epoc": 0.1,
            "cardio": 0.1,
            "metabolic": 0.1,
            "strength": 0.1
          }
        }
      },
      "forAfterburner": { // Afterburner clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "wktdef1": {
          "recommended": "", // Not recommended, just visible
	      "locked": false, // Available to user
		  "lockString": "",
          "MWI": 0.54,
          "breakdown": {
            "epoc": 0.1,
            "cardio": 0.1,
            "metabolic": 0.1,
            "strength": 0.1
          }
        },
        "wktdef2": {
          "recommended": "You need to work on your abs", // Recommended and reason for this to be shown to user
		  "locked": false, // Available to user
		  "lockString": "",
          "MWI": 0.54,
          "breakdown": {
            "epoc": 0.1,
            "cardio": 0.1,
            "metabolic": 0.1,
            "strength": 0.1
          }
        }
      }
    }
  },
  "workouts": {
    "activities": {
      "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "workout_id_01": { // Clients post new activity to here with auto id, server listens
          "workoutDefId": "wktdef1", // [no default]
          "finish": 987654345, // Unix timestamp (seconds) [default:0]
          "iterations": 1.5, // Number of times it was performed [default:1]
          "exertion": 0.5, // [default:0.5]
          "finalHeartRateBPM": 160, // [default:140]
          "finalHeartRateDelay": 0, // Length of delay (in secs) after the workout before the HR was measured (0 if they didn't press the 'start again' button) [default:0]
		  "app": "7MW" // Short code of the app the activity was performed in: 7MW, AF, etc [default:null]
        }
      }
    },
    "results": {
      "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "workout_id_01": { // Server posts workout results here
          "workoutDefId": "wktdef1", // [no default]
          "finish": 987654345, // Unix timestamp (seconds) // [no default]
          "AWI": 0.1, // [default:0.5]
          "responseDuration": 3456, // [default: 0]
          "intensity": 0.9, // [default:0.5]
		  "app": "7MW", // Short code of the app the activity was performed in: 7MW, AF, etc [no default]
          "responses": { // [no default]
            "cardio": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "strength": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "epoc": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "metabolic": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            }
          },
          "muscleGroups": {
            "upper": 0.3, // [default: 0.3]
            "lower": 0.3, // [default: 0.3]
            "core": 0.4 // [default: 0.3]
          }
        }
      }
    }
  },
  "afterburn": {
    "user_id_01": { // Clients listen here permanently
      "start": 345678987, // Unix timestamp (seconds) // [no default]
      "response": { // [default:null]
        "resolution": 600, // Secs
        "epoc": [0.6,0.5,0.3,0.2,0.1,0.0],
        "cardio": [0.6,0.5,0.3,0.2,0.1,0.0],
        "strength": [0.6,0.5,0.3,0.2,0.1,0.0],
        "metabolic": [0.6,0.5,0.3,0.2,0.1,0.0]
      },
      "impactCredit": { // [default:null]
        "resolution": 600, // Secs
        "futureCredit": 0.9,
        "pending": [0.0,0.1,0.2,0.3,0.4,0.5]
      },
      "messages": [ // Messages displayed below the radar chart [default:null]
        {"t":0,"body":"Restoring body temperature", "detail": ""},
        {"t":120,"body":"Replenishing glycogen stores", "detail": "detail/glycogen"}
      ],
      "notifications": [ // [default:null]
        {"t":6000,"body":"Great workout! You're still burning calories and building strength."},
        {"t":14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
      ]
    }
  },
  "timelineArticles": {
    "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "article_id_01": {
        "date": 4567890987, // Unix timestamp (seconds) // [no default]
        "title": "Post title", // [no default]
        "read": false, // [default:true]
        "location": "post/location.html", // [no default]
		"icon": "default", // [default:"default"]
        "appMask": "7MW,AF" // [default: all apps]
      }
    }
  },
  "definitions": {
    "exerciseDefs": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "exdef1": {
        "behaviour": 1, // [default:1]
        "title": "Cruches", // [no default]
        "video": "01-Crunches.mp4", // [no default]
        "image": "abs", // [default:"default"]
        "desc": "A crunch begins with lying face up on the floor with knees bent. The movement begins by curling the shoulders towards the pelvis. The hands can be behind or beside the neck or crossed over the chest. Injury can be caused by pushing against the head or neck with hands.", // [default:null]
        "subtitle": "Target your abs for a balanced set of stomach muscles.", // [default:null]
        "calPerSec": 5, // [default:0]
        "skill": 0.2, // [default:0.5]
        "strength": 0.7, // [default:0.5]
        "cardio": 0.1, // [default:0.5]
        "epoc": 0.4, // [default:0.5]
        "metabolic": 0.4, // [default:0.5]
        "upper": 0.5, // [default:0.5]
        "core": 0.5, // [default:0.5]
        "lower": 0.5 // [default:0.5]
      },
      "exdef2": {
        "behaviour": 1,
        "title": "Squats",
        "video": "02-Squats.mp4",
        "image": "abs",
        "desc": "Squats are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",
        "subtitle": "Train your lower body and core.",
        "calPerSec": 4,
        "skill": 0.2,
        "strength": 0.6,
        "cardio": 0.3,
        "epoc": 0.4,
        "metabolic": 0.6,
        "upper": 0.5,
        "core": 0.5,
        "lower": 0.5
      }
    },
    "workoutDefs": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "wktdef1": {
        "type": 1, // [default:1]
        "title": "Aerobic", // [no default]
        "image": "abs", // [default:"default"]
        "desc": "Aerobic Basic Movement", // [default:null]
        "breakDuration": 5, // // [default:10]
		"appStoreId: "workout01", // StoreKit product id [default:null]
        "in7MW": true, // For server use [default:false]
        "inAfterburner": false, // For server use [default:false]
        "exercises": [ // [no default]
          {
            "id": "exdef1", // [no default]
            "duration": 20 // [no default]
          },
          {
            "id": "exdef2",
            "duration": 15
          },
          {
            "id": "exdef3",
            "duration": 10
          },
          {
            "id": "exdef4",
            "duration": 5
          },
          {
            "id": "exdef5",
            "duration": 10
          }
        ],
        "adaptiveStress": {
          "strength": 0.2, // [default:1]
          "cardio": 0.9, // [default:1]
          "metabolic": 0.6, // [default:1]
          "epoc": 0.6 // [default:1]
        },
        "muscleStress": {
          "upper": 10, // [default:1]
          "lower": 10, // [default:1]
          "core": 10 // [default:1]
        }
      },
      "wktdef2": {
        "type": 1,
        "title": "Thai Boxing",
        "image": "abs",
        "desc": "Boxing With Kicking",
        "breakDuration": 4,
		"appStoreId: "", // StoreKit product id
        "in7MW": false, // For server use
        "inAfterburner": true, // For server use
        "exercises": [
          {
            "id": "exdef5",
            "duration": 15
          },
          {
            "id": "exdef3",
            "duration": 10
          },
          {
            "id": "exdef1",
            "duration": 5
          }
        ],
        "stress": {
          "strength": 0.2,
          "cardio": 0.9,
          "metabolic": 0.6,
          "epoc": 0.6
        },
        "muscleStress": {
          "upper": 10,
          "lower": 10,
          "core": 10
        }
      }
    },
    "journeyTriggers: {
      "forAfterburner": {
        "trigger01": {
          "category": "achievement",
          "triggerType": "activeDaysInWeeks",
          "condition1": 4, // 4 active days
          "condition2": 8, // every week for 8 weeks
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
            {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
          ]
        },
        "trigger02": {
          "category": "education",
          "triggerType": "totalActivities",
          "condition1": 10, // 10 activities
          "condition2": 0, // Not used
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
          ]
        }
      },
      "for7MW": {
        "trigger01": {
          "category": "achievement",
          "triggerType": "activeDaysInWeeks",
          "condition1": 4, // 4 active days
          "condition2": 8, // every week for 8 weeks
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
            {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
          ]
        },
        "trigger02": {
          "category": "education",
          "triggerType": "totalActivities",
          "condition1": 10, // 10 activities
          "condition2": 0, // Not used
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
          ]
        }
      }
    }
  }
}

Client-Side Data Validation & Error Handling

We apply the following process to validate data on the client and to handle the errors appropriately:

SituationActions
  • Property is missing or is wrong type
  • Property has a default defined in the model schema.
  • Log error to crashlytics.
  • Handle silently and apply default value.
  • Property is missing or is wrong type
  • Property doesn't have a default defined.
  • Log error to crashlytics.
  • Throw exception (catch the exception according to object-specific rules, see below).
  • Entire object is missing
  • Log error to crashlytics.
  • Throw exception (catch the exception according to object-specific rules, see below).

Data Validation Exception Handling

EntityChecksAction
visibleWorkoutDef
  • Missing properties without defaults.
  • Missing or invalid workout definition.
Hide from user.
exerciseDefinition
  • Missing properties without defaults.
Tell user via alert view.
timelineArticle
  • Missing properties without defaults.
Hide from user.
activity
  • Missing properties without defaults.
Tell user via alert view.
result
  • Missing properties without defaults.
Tell user via alert view.
afterburn
  • Missing properties without defaults.
Tell user via alert view.
userN/A (all properties have defaults)None


  • No labels