ui/usage.go
func (h *Handler) GetProductUsage(password, productID string) (*uint, error) {
	logger := h.logger.Add("method", "GetProductUsage",
		"productID", productID)

	return h.uintFromQuery(logger, password,
		`SELECT SUM(sessions.units_used)
		   FROM offerings
		   	JOIN channels
			ON channels.offering=offerings.id
			   AND offerings.product=$1
		   	JOIN sessions
		     	ON sessions.channel=channels.id`, productID)
}
func (h *Handler) GetProductUsage(password, productID string) (*uint, error) {
	logger := h.logger.Add("method", "GetProductUsage",
		"productID", productID)

	return h.uintFromQuery(logger, password,
		`SELECT SUM(sessions.units_used)
		   FROM offerings
		   	JOIN channels
			ON channels.offering=offerings.id
			   AND offerings.product=$1
		   	JOIN sessions
		     	ON sessions.channel=channels.id`, productID)
}
// GetProductUsage returns total units used in all channel
// of all offerings with given product.