Status serializeQueryLogItemAsEvents(const QueryLogItem& item, JSON& doc) { auto temp_doc = JSON::newObject(); if (!item.results.added.empty() || !item.results.removed.empty()) { auto status = serializeDiffResults( item.results, item.columns, temp_doc, temp_doc.doc()); if (!status.ok()) { return status; } } else if (!item.snapshot_results.empty()) { auto arr = doc.getArray(); auto status = serializeQueryData(item.snapshot_results, {}, temp_doc, arr); if (!status.ok()) { return status; } temp_doc.add("snapshot", arr); } else { // This error case may also be represented in serializeQueryLogItem. return Status(1, "No differential or snapshot results"); } for (auto& action : temp_doc.doc().GetObject()) { for (auto& row : action.value.GetArray()) { auto obj = doc.getObject(); serializeEvent(item, row, doc, obj); doc.addCopy("action", action.name.GetString(), obj); doc.push(obj); } } return Status(); }
Status serializeQueryLogItemAsEvents(const QueryLogItem& i, pt::ptree& tree) { pt::ptree diff_results; auto status = serializeDiffResults(i.results, diff_results); if (!status.ok()) { return status; } for (auto& action : diff_results) { for (auto& row : action.second) { pt::ptree event; serializeEvent(i, row.second, event); event.put<std::string>("action", action.first); tree.push_back(std::make_pair("", event)); } } return Status(0, "OK"); }
Status serializeQueryLogItemAsEvents(const QueryLogItem& i, pt::ptree& tree) { pt::ptree diff_results; // Note, snapshot query results will bypass the "AsEvents" call, even when // log_result_events is set. This is because the schedule will call an // explicit ::logSnapshotQuery, which does not check for the result_events // configuration. auto status = serializeDiffResults(i.results, diff_results); if (!status.ok()) { return status; } for (auto& action : diff_results) { for (auto& row : action.second) { pt::ptree event; serializeEvent(i, row.second, event); event.put<std::string>("action", action.first); tree.push_back(std::make_pair("", event)); } } return Status(0, "OK"); }
Status serializeScheduledQueryLogItemAsEvents( const ScheduledQueryLogItem& item, boost::property_tree::ptree& tree) { try { pt::ptree diff_results; auto status = serializeDiffResults(item.diffResults, diff_results); if (!status.ok()) { return status; } for (auto& i : diff_results) { for (auto& j : i.second) { pt::ptree event; serializeEvent(item, j.second, event); event.put<std::string>("action", i.first); tree.push_back(std::make_pair("", event)); } } } catch (const std::exception& e) { return Status(1, e.what()); } return Status(0, "OK"); }