-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapi_client.hpp
More file actions
57 lines (40 loc) · 1.29 KB
/
api_client.hpp
File metadata and controls
57 lines (40 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <chrono>
#include "lang/program.hpp"
#include "mine/submission.hpp"
#include "sys/jute.h"
class ApiClient {
public:
ApiClient();
static ApiClient& getDefaultInstance();
std::string toJson(const Program& program);
void postProgram(const Program& program, size_t max_buffer = 0);
// void postSubmission(const Submission& submission, size_t max_buffer = 0);
bool postSubmission(const std::string& path, bool fail_on_error = true);
void postCPUHour();
void getOeisFile(const std::string& filename, const std::string& local_path);
void reportBrokenBFile(const UID& id);
Submission getNextSubmission();
private:
// throttle download of OEIS file from API server
static constexpr int64_t OEIS_THROTTLING_SECS = 10; // magic number
class Page {
public:
int64_t limit;
int64_t skip;
};
std::string base_url_v2;
bool oeis_fetch_direct;
int64_t client_id;
int64_t session_id;
int64_t start;
int64_t count;
int64_t fetched_oeis_files;
std::vector<Page> pages;
std::vector<Submission> in_queue;
std::vector<Program> out_queue;
std::chrono::time_point<std::chrono::steady_clock> last_oeis_time;
bool printed_throttling_warning;
void updateSession();
jute::jValue getSubmissions(const Page& page, Submission::Type type);
};