HabitRPG/habitrpg — pull request #3884 by Alys (2014-08-17 07:41:42+00:00)
Title: count how many users own specified gear with mongodb JavaScript

@lefnire @lemoness @caffeinatedvee

This is related to the discussion in the Magical Fun-Times Dazzle Emporium, in which Lemoness said _"we do NOT have any info on things that people can get without purchasing, like the Unconventional Armor - and it would be fantastic to know how many people have that, especially if we could link it to time periods, because then we could know roughly how many people signed up post-conferences."_

This is a script designed to be run by lefnire in mongodb. It looks through all user accounts and tallies up the number of people who own a specific item (no information about specific people is produced; just total ownership numbers).

The array ````itemsOfInterest```` must contain the keys of the items to be counted. Currently it contains all of the [Unconventional Armor](http://habitrpg.wikia.com/wiki/Unconventional_Armor) and nothing else.

The totals are output in two formats: CSV for importing into a spreadsheet, and a more readable format. Sample output is below.

It is not possible to find out when each person obtained the gear (at least not from the mongodb data that I'm aware of). However, you could run this report after each convention to compare numbers with previous runs (hence the date field in the CSV data).

If you would like human-friendly names for the gear to be included instead of or as well as the keys (e.g., "Mighty Mask" instead of "headAccessory_special_wondercon_red"), tell me because I can do that easily enough. And I can make any other changes required. :)

Sample output:
````
CSV DATA:

"date","headAccessory_special_wondercon_red","headAccessory_special_wondercon_black","back_special_wondercon_black","back_special_wondercon_red","body_special_wondercon_red","body_special_wondercon_black","body_special_wondercon_gold"
"2014-08-17","5","4","3","3","3","3","3"

READABLE DATA:

2014-08-17
{
"headAccessory_special_wondercon_red": 5,
"headAccessory_special_wondercon_black": 4,
"back_special_wondercon_black": 3,
"back_special_wondercon_red": 3,
"body_special_wondercon_red": 3,
"body_special_wondercon_black": 3,
"body_special_wondercon_gold": 3
}
````