modubot / modubot.js

Modubot: the scalable and extensible IRC bot.
https://modubot.net
BSD 3-Clause "New" or "Revised" License
19 stars 3 forks source link

[axxim/factoids] Add counter for factoid use #42

Closed yuna9 closed 10 years ago

yuna9 commented 10 years ago

It would be very cool to see a counter for how many times a factoid has been used. It can then be combined with the age of the factoid to see the frequency of use over a day, for example.

kamaln7 commented 10 years ago

That's a good idea, I'm not sure a simple counter field would work for something like a usage frequency graph. I'm thinking something like this (the hits array):

{
    "_id": ObjectId(),
    "factoid": "mysqltuner",
    "content": "https://raw.github.com/major/MySQLTuner-perl/master/mysqltuner.pl",
    "owner": "kamal_",
    "channel": "",
    "createdAt": ISODate("2013-09-24T17:40:36.177Z"),
    "locked": false,
    "forgotten": false,
    "hits": [
        ISODate("2013-09-24T17:40:36.177Z"),
        ISODate("2013-09-25T17:40:36.177Z")
    ]
    "__v": 0
}

How does that sound?

yuna9 commented 10 years ago

Sounds good and looks nice to me. What is __v?

kamaln7 commented 10 years ago

Mongoose (the MongoDB ORM that Modubot uses) adds that: http://mongoosejs.com/docs/guide.html#versionKey

Not sure how searchable an array of dates would be, though. I'll have to test it.

kamaln7 commented 10 years ago

Done: d5570a4b4d07c58a0357ee8919f5be57829d4393