Skip to content

Commit

Permalink
Merge pull request #822 from Expensify/master
Browse files Browse the repository at this point in the history
Update expensify_prod branch
  • Loading branch information
johnmlee101 authored Jul 23, 2020
2 parents a021597 + 33f5616 commit 0060fb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions plugins/Jobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ BedrockJobsCommand::BedrockJobsCommand(SQLiteCommand&& baseCommand, BedrockPlugi
{
}

BedrockPlugin_Jobs::BedrockPlugin_Jobs(BedrockServer& s) : BedrockPlugin(s)
BedrockPlugin_Jobs::BedrockPlugin_Jobs(BedrockServer& s) :
BedrockPlugin(s),
isLive(server.args.isSet("-live"))
{
}

Expand Down Expand Up @@ -97,12 +99,10 @@ void BedrockPlugin_Jobs::upgradeDatabase(SQLite& db) {
"parentJobID INTEGER NOT NULL DEFAULT 0, "
"retryAfter TEXT NOT NULL DEFAULT \"\")",
ignore));

// These indexes are not used by the Bedrock::Jobs plugin, but provided for easy analysis
// using the Bedrock::DB plugin.
SASSERT(db.write("CREATE INDEX IF NOT EXISTS jobsName ON jobs ( name );"));
SASSERT(db.write("CREATE INDEX IF NOT EXISTS jobsParentJobIDState ON jobs ( parentJobID, state ) WHERE parentJobID != 0;"));
SASSERT(db.write("CREATE INDEX IF NOT EXISTS jobsStatePriorityNextRunName ON jobs ( state, priority, nextRun, name );"));
// verify and conditionally create indexes
SASSERT(db.verifyIndex("jobsName", "jobs", "( name )", false, !BedrockPlugin_Jobs::isLive));
SASSERT(db.verifyIndex("jobsParentJobIDState", "jobs", "( parentJobID, state ) WHERE parentJobID != 0", false, !BedrockPlugin_Jobs::isLive));
SASSERT(db.verifyIndex("jobsStatePriorityNextRunName", "jobs", "( state, priority, nextRun, name )", false, !BedrockPlugin_Jobs::isLive));
}

// ==========================================================================
Expand Down Expand Up @@ -1238,7 +1238,7 @@ void BedrockJobsCommand::process(SQLite& db) {
else if (SIEquals(requestVerb, "RequeueJobs")) {
SINFO("Requeueing jobs with IDs: " << request["jobIDs"]);
list<int64_t> jobIDs = SParseIntegerList(request["jobIDs"]);

if (jobIDs.size()) {
const string& name = request["name"];
string nameQuery = name.empty() ? "" : ", name = " + SQ(name) + "";
Expand Down
2 changes: 2 additions & 0 deletions plugins/Jobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class BedrockPlugin_Jobs : public BedrockPlugin {
// Set of supported verbs for jobs with case-insensitive matching.
static const set<string,STableComp>supportedRequestVerbs;

const bool isLive;

private:
static int64_t getNextID(SQLite& db);
static const string name;
Expand Down

0 comments on commit 0060fb2

Please sign in to comment.