1212static const char USAGE[] =
1313R"(
1414 Usage:
15- stories [--top=<top>] [--days=<days>] [--oddbean]
15+ stories [--top=<top>] [--days=<days>] [--threshold=<threshold>] [-- oddbean]
1616)" ;
1717
1818
1919struct EventInfo {
2020 uint64_t comments = 0 ;
2121 uint64_t reactions = 0 ;
22+ double score = 0 ;
2223};
2324
2425struct FilteredEvent {
@@ -36,12 +37,13 @@ void cmd_stories(const std::vector<std::string> &subArgs) {
3637 if (args[" --top" ]) top = args[" --top" ].asLong ();
3738 uint64_t days = 2 ;
3839 if (args[" --days" ]) days = args[" --days" ].asLong ();
40+ uint64_t threshold = 10 ;
41+ if (args[" --threshold" ]) threshold = args[" --threshold" ].asLong ();
3942 bool oddbeanOnly = args[" --oddbean" ].asBool ();
4043
4144 uint64_t eventLimit = 1000 ;
4245 uint64_t scanLimit = 100000 ;
4346 uint64_t timeWindow = 86400 *days;
44- uint64_t threshold = 10 ;
4547
4648 Decompressor decomp;
4749 auto txn = env.txn_ro ();
@@ -91,7 +93,10 @@ void cmd_stories(const std::vector<std::string> &subArgs) {
9193 if (tArr.at (0 ) == " client" && tArr.size () >= 2 && tArr.at (1 ) == " oddbot" ) return true ;
9294 }
9395 } else {
94- if (eventInfo.reactions < threshold) return true ;
96+ eventInfo.score = 0 ;
97+ eventInfo.score += eventInfo.reactions ;
98+ eventInfo.score += (double )eventInfo.comments * 2 ;
99+ if (eventInfo.score < threshold) return true ;
95100 }
96101
97102 output.emplace_back (FilteredEvent{ev.primaryKeyId , id, packed.created_at (), eventInfo});
@@ -118,7 +123,7 @@ void cmd_stories(const std::vector<std::string> &subArgs) {
118123
119124 if (!oddbeanOnly) {
120125 std::sort (output.begin (), output.end (), [](const auto &a, const auto &b){
121- return a.info .reactions > b.info .reactions ;
126+ return a.info .score > b.info .score ;
122127 });
123128 }
124129
@@ -139,6 +144,7 @@ void cmd_stories(const std::vector<std::string> &subArgs) {
139144 { " timestamp" , ev.at (" created_at" ) },
140145 { " reactions" , o.info .reactions },
141146 { " comments" , o.info .comments },
147+ { " score" , o.info .score },
142148 });
143149
144150 std::cout << tao::json::to_string (encoded) << " \n " ;
0 commit comments