This commit is contained in:
Doug Hoyte
2023-06-10 01:54:23 -04:00
parent 542552ab0f
commit 4c0ce3df0b
46 changed files with 8174 additions and 1 deletions

56
src/apps/web/cmd_algo.cpp Normal file
View File

@ -0,0 +1,56 @@
#include <docopt.h>
#include "golpe.h"
#include "WebData.h"
#include "AlgoScanner.h"
#include "Decompressor.h"
static const char USAGE[] =
R"(
Usage:
algo scan <descriptor>
)";
void cmd_algo(const std::vector<std::string> &subArgs) {
std::map<std::string, docopt::value> args = docopt::docopt(USAGE, subArgs, true, "");
std::string descriptor = args["<descriptor>"].asString();
UserCache userCache;
Decompressor decomp;
auto txn = env.txn_ro();
auto communitySpec = lookupCommunitySpec(txn, decomp, userCache, descriptor);
AlgoScanner a(txn, communitySpec.algo);
auto events = a.getEvents(txn, decomp, 300);
for (const auto &e : events) {
auto ev = Event::fromLevId(txn, e.levId);
ev.populateJson(txn, decomp);
std::cout << e.info.score << "/" << e.info.comments << " : " << ev.summaryHtml() << "\n";
}
/*
std::string str;
{
std::string line;
while (std::getline(std::cin, line)) {
str += line;
str += "\n";
}
}
auto alg = parseAlgo(txn, str);
for (const auto &[k, v] : alg.variableIndexLookup) {
LI << k << " = " << alg.pubkeySets[v].size() << " recs";
}
*/
}