Overides impressionist_count in order to provide mongoid compability
979747
def impressionist_count(options={})

      # Uses these options as defaults unless overridden in options hash
      options.reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now)

      # If a start_date is provided, finds impressions between then and the end_date.
      # Otherwise returns all impressions
      imps = options[:start_date].blank? ? impressions :
        impressions.between(created_at: options[:start_date]..options[:end_date])


      # Count all distinct impressions unless the :all filter is provided
      distinct = options[:filter] != :all
      distinct ? imps.where(options[:filter].ne => nil).distinct(options[:filter]).count : imps.count
    end
56346
function getMongoModelForEntity(entity) {
	
	const entityName = entity.setEntityName();
	
	if(!models.hasOwnProperty(entity.setEntityName()))
	{
		models[entityName] = convertPAIEntityToMongoSchema(entity);
		
		PAILogger.info("MongoDB Model just created: " + entityName);
	}
	
	return models[entityName];
}
805697
def countables
      key :type, :int
      key :ts, :timestamp
      key :uid, :text

      column :count, :bigint

      generate_aggregators { |ts, method|
        totype = method_names_type_counter(method)
        fromtype = get_fromtype_for_totype(totype)
        aggregate_and_create(fromtype, totype, ts)
      }
    end
61230
function count(req, res, next) {
  db.posts.count(function(err, count) {
    if(err) { return next(err); }
    res.json({count: count});
  });
}
97914
def parse(argv)
      parser        = OptionParser.new do |o|
        o.on('-c',
             '--count COUNT',
             'Count of jobs to enqueue') do |arg|
          self.count = arg.to_i
        end
        o.on('-m',
             '--mongo MONGO_CONFIG_FILE_NAME',
             'Path and filename of config file. Default: config/mongoid.yml') do |arg|
          self.mongo_config = arg
        end
        o.on('-e',
             '--environment ENVIRONMENT',
             'The environment to run the app on (Default: RAILS_ENV || RACK_ENV || development)') do |arg|
          self.environment = arg
        end
      end
      parser.banner = 'rocketjob_perf <options>'
      parser.on_tail '-h', '--help', 'Show help' do
        puts parser
        exit 1
      end
      parser.parse! argv
    end
1079045
def many(cls, filter=None, **kwargs):
        """"""
        from mongoframes.queries import Condition, Group, to_refs

        # Flatten the projection
        kwargs['projection'], references, subs = \
                cls._flatten_projection(
                    kwargs.get('projection', cls._default_projection)
                    )

        # Find the documents
        if isinstance(filter, (Condition, Group)):
            filter = filter.to_dict()

        documents = list(cls.get_collection().find(to_refs(filter), **kwargs))

        # Dereference the documents (if required)
        if references:
            cls._dereference(documents, references)

        # Add sub-frames to the documents (if required)
        if subs:
            cls._apply_sub_frames(documents, subs)

        return [cls(d) for d in documents]
140363
def _initialize_counters(model_class, name, bases, attrs):
    """"""
    model_class._counters = []
    for k, v in attrs.iteritems():
        if isinstance(v, Counter):
            model_class._counters.append(k)
351844
def set_item_count
  	  m = model_with_includes.where(self.where)
  	  n = self.near
  	  m = m.near(n[0], n[1]) if n
  	  @options['item_count'] = m.count
  	end
251229
def view_num_units(token, dstore):
    
    taxo = dstore['assetcol/tagcol/taxonomy'].value
    counts = collections.Counter()
    for asset in dstore['assetcol']:
        counts[taxo[asset['taxonomy']]] += asset['number']
    data = sorted(counts.items())
    data.append(('*ALL*', sum(d[1] for d in data)))
    return rst_table(data, header=['taxonomy', 'num_units'])
497301
def render_enriched_record(document)
      agg = document.aggregation
      return error_msg('Aggregation not found.') unless agg.present?
      JSON.pretty_generate(agg.to_jsonld['@graph'])
    end
550018
def field_names(options)
      names = (as_attributes.keys + attribute_names).uniq.sort

      only = Array.wrap(options[:only]).map(&:to_s)
      except = Array.wrap(options[:except]).map(&:to_s)
      except |= ['_type'] unless Mongoid.include_type_for_serialization

      if !only.empty?
        names &= only
      elsif !except.empty?
        names -= except
      end
      names
    end
558881
def count
      users_count = MnoEnterprise::Tenant.get('tenant').users_count
      render json: {count: users_count }
    end
827506
def aggregate_and_create(oftype, ts = Time.now.floor)
      Octo::Enterprise.each do |enterprise|
        calculate(enterprise.id, oftype, ts)
      end
    end
760141
def annex_block(identifier, opts = {})
      opts[:route] ||= current_route

      case Annex::config[:adapter]

      when :activerecord
        doc = Annex::Block.where(route: "#{opts[:route]}_#{identifier}").first_or_create
        content = doc.content

      when :mongoid
        doc = Annex::Block.where(route: opts[:route]).first_or_create
        content = doc.content.try(:[], identifier.to_s)

      end

      render partial: 'annex/block', locals: { content: content || opts[:default], identifier: identifier, opts: opts }
    end
1353860
def required_attributes
      validators.map{ |v| v.attributes if v.is_a?(Mongoid::Validations::PresenceValidator) }.flatten.compact
    end
29335
function collectionCount(name, qry, opts) {
      return Crux.promise(function(resolve, reject) {
        var col = self.mongo.connection.db.collection(name);
        col.count(qry, opts || {}, function(err, count) {
          if(err) {
            return reject(err);
          }
          resolve(count);
        });
      });
    }
1344288
def artists_in_collection(start=nil,count=nil,sort=nil,
                              query=nil,extras=nil)
      api.getArtistsInCollection self,start,count,sort,query,extras
    end