{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "bookSummary": {
      "properties": {
        "authors": {
          "type": "string"
        },
        "cover": {
          "type": "string"
        },
        "hiveId": {
          "type": "string"
        },
        "pageCount": {
          "type": "integer"
        },
        "rating": {
          "type": "integer"
        },
        "thumbnail": {
          "type": "string"
        },
        "title": {
          "type": "string"
        }
      },
      "required": [
        "hiveId",
        "title",
        "authors"
      ],
      "type": "object"
    },
    "genreStat": {
      "properties": {
        "count": {
          "minimum": 0,
          "type": "integer"
        },
        "genre": {
          "type": "string"
        }
      },
      "required": [
        "genre",
        "count"
      ],
      "type": "object"
    },
    "main": {
      "description": "Get reading statistics for a user for a given year.",
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "availableYears": {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            "stats": {
              "ref": "buzz.bookhive.getReadingStats#readingStats",
              "type": "ref"
            },
            "year": {
              "type": "integer"
            }
          },
          "required": [
            "stats",
            "availableYears",
            "year"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "handle": {
            "description": "The user handle or DID",
            "type": "string"
          },
          "year": {
            "description": "The year to fetch stats for. Defaults to current year.",
            "maximum": 2100,
            "minimum": 2000,
            "type": "integer"
          }
        },
        "required": [
          "handle"
        ],
        "type": "params"
      },
      "type": "query"
    },
    "ratingDistribution": {
      "properties": {
        "five": {
          "minimum": 0,
          "type": "integer"
        },
        "four": {
          "minimum": 0,
          "type": "integer"
        },
        "one": {
          "minimum": 0,
          "type": "integer"
        },
        "three": {
          "minimum": 0,
          "type": "integer"
        },
        "two": {
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "one",
        "two",
        "three",
        "four",
        "five"
      ],
      "type": "object"
    },
    "readingStats": {
      "properties": {
        "averagePageCount": {
          "type": "integer"
        },
        "averageRating": {
          "description": "Average rating * 10 (e.g. 42 = 4.2 stars)",
          "type": "integer"
        },
        "booksCount": {
          "minimum": 0,
          "type": "integer"
        },
        "firstBookOfYear": {
          "ref": "buzz.bookhive.getReadingStats#bookSummary",
          "type": "ref"
        },
        "lastBookOfYear": {
          "ref": "buzz.bookhive.getReadingStats#bookSummary",
          "type": "ref"
        },
        "leastPopularBook": {
          "ref": "buzz.bookhive.getReadingStats#bookSummary",
          "type": "ref"
        },
        "longestBook": {
          "ref": "buzz.bookhive.getReadingStats#bookSummary",
          "type": "ref"
        },
        "mostPopularBook": {
          "ref": "buzz.bookhive.getReadingStats#bookSummary",
          "type": "ref"
        },
        "pagesRead": {
          "minimum": 0,
          "type": "integer"
        },
        "ratingDistribution": {
          "ref": "buzz.bookhive.getReadingStats#ratingDistribution",
          "type": "ref"
        },
        "shortestBook": {
          "ref": "buzz.bookhive.getReadingStats#bookSummary",
          "type": "ref"
        },
        "topGenres": {
          "items": {
            "ref": "buzz.bookhive.getReadingStats#genreStat",
            "type": "ref"
          },
          "type": "array"
        }
      },
      "required": [
        "booksCount",
        "ratingDistribution",
        "topGenres"
      ],
      "type": "object"
    }
  },
  "id": "buzz.bookhive.getReadingStats",
  "lexicon": 1
}
