npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

region-list-aggregator

v0.1.0

Published

Compiles lists of content base on defined filtering and ordering

Downloads

10

Readme

region-list-aggregator

Compiles lists of content base on defined filtering and ordering.

Installation

  npm install region-list-aggregator

Usage

var aggregate = createAggregator(listService, sectionService, articleService, { logger: logger })

aggregate(listId, dedupe, limit, section, function (err, results) {})

Date based previewing

To create a list aggregator which allows searching from any date perspective, pass a date parameter into the options object like so:

var aggregate = createAggregator(listService, sectionService, articleService, { logger: logger, date: new Date() })

This aggregator instance now performs all operations based on this date.

Specifying fields to return

To specify fields to return from the query, use the fields option. This field can either be an object or an array - mongo is tolerant of either.

An object can be like so:

  fields: { longTitle: 1, tags: 1 }

Or an array:

  fields: ['longTitle', 'tags']

Example:

var aggregate = createAggregator(listService, sectionService, articleService, { logger: logger, fields: { longTitle: 1 } })

Types of list

There are two types of list:

### 1. Automatic Automatic lists are used to auto-generate list content based on a number of properties:

  • tags
  • sections
  • regions
  • articletypes
  • articleSubTypes

They can be sorted by:

  • recent
  • most comments
  • popular
  • alphabetical

### 2. Manual Manual lists are specific lists of articles or content.

Types of list content

There are three types of content that can be present in a list:

Warning: some fields below are omitted for brevity

### 1. Article This is a standard article, obtained directly from the article collection. These can be present in both automatic and manual lists. They are stored in the list entity under the articles array like so:

"articles" : [
    {
      "articleId" : "52551b0bd50e51ce03000002",
      "type" : "offer"
    },
    {
      "articleId" : "51ed3d294ca3ce512f00000a",
      "type" : "offer"
    }
  ]

2. Overridden article

This is a standard article with some fields overridden. For example if an article title was "My amazing article", but you wanted it to appear in a list with the title "Click to see my amazing title".

These fields are also stored in the articles array alongside normal articles like so:

"articles" : [
    {
      "articleId" : "52551b0bd50e51ce03000002",
      "type" : "offer"
    },
    {
      "articleId" : "51ed3d294ca3ce512f00000a",
      "shortTitle" : "New overridden title",
      "type" : "offer",
      "customId": null
    }
  ]

They are differentiated from custom articles by having a customId value of null and an articleId relating to an actual article.

Date fields (liveDate and expiryDate) can also be overridden to effect the articles visibility within a list. This does not affect an article's visibility anywhere but this list.

3. Custom item

Custom items are pieces of content which have no related article. They can be used to put arbitrary data within a list. They also appear in the articles array like so:

"articles" : [
    {
      "articleId" : "52551b0bd50e51ce03000002",
      "type" : "offer"
    },
    {
      "articleId" : null,
      "shortTitle" : "asddsa",
      "type" : "custom",
      "customId" : 1
    }
  ]

They always have a customId integer, an articleId of null and a type of custom to differentiate from overridden articles.

Credits

Paul Serby follow me on twitter @serby

Licence

Licensed under the New BSD License