code: func (ssa *SQLStorageAuthority) CountInvalidAuthorizations(
  	ctx context.Context,
  	req *sapb.CountInvalidAuthorizationsRequest,
  ) (count *sapb.Count, err error) {
  	identifier := core.AcmeIdentifier{
  		Type:  core.IdentifierDNS,
  		Value: *req.Hostname,
  	}
  
  	idJSON, err := json.Marshal(identifier)
  	if err != nil {
  		return nil, err
  	}
  
  	count = &sapb.Count{
  		Count: new(int64),
  	}
  	err = ssa.dbMap.WithContext(ctx).SelectOne(count.Count,
  		`SELECT COUNT(1) FROM authz
  		WHERE registrationID = :regID AND
  		identifier = :identifier AND
  		expires > :earliest AND
  		expires <= :latest AND
  		status = :invalid`,
  		map[string]interface{}{
  			"regID":      *req.RegistrationID,
  			"identifier": idJSON,
  			"earliest":   time.Unix(0, *req.Range.Earliest),
  			"latest":     time.Unix(0, *req.Range.Latest),
  			"invalid":    string(core.StatusInvalid),
  		})
  	return
  }
docs: // CountInvalidAuthorizations counts invalid authorizations for a user expiring
  // in a given time range.
  // authorizations for the give registration.