Skip to content

Commit 6b1b1d7

Browse files
committed
add optimize system/ meta/ branch/ commit api
1 parent dff54d3 commit 6b1b1d7

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

lib/connectionConfig.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,33 @@ ConnectionConfig.prototype.squashBranchURL = function(nuid) {
391391
* Generate URL for optimizing system
392392
*/
393393
ConnectionConfig.prototype.optimizeSystemUrl = function() {
394-
return `${this.apiURL()}optimize/_system`
394+
let o = this.optimizeBase()
395+
return o + `_system`
396+
}
397+
398+
/**
399+
* Generate URL for optimizing db meta
400+
*/
401+
ConnectionConfig.prototype.optimizeMetaUrl = function() {
402+
let o = this.optimizeBase()
403+
return o + `${this.user()}/${this.db()}/_meta`
404+
}
405+
406+
/**
407+
* Generate URL for optimizing db commits
408+
*/
409+
ConnectionConfig.prototype.optimizeCommitUrl = function() {
410+
let o = this.optimizeBase()
411+
return o + `${this.user()}/${this.db()}/${this.repoid}/_commits`
412+
}
413+
414+
/**
415+
* Generate URL for optimizing db branch
416+
*/
417+
418+
ConnectionConfig.prototype.optimizeBranchUrl = function(nuid) {
419+
let o = this.optimizeBase()
420+
return o + `${this.user()}/${this.db()}/${this.repoid}/branch/${nuid}`
395421
}
396422

397423
/**
@@ -411,6 +437,13 @@ ConnectionConfig.prototype.repoBase = function(action) {
411437
return b
412438
}
413439

440+
/**
441+
* Generate base optimize url consisting of server
442+
*/
443+
ConnectionConfig.prototype.optimizeBase = function() {
444+
return `${this.apiURL()}optimize/`
445+
}
446+
414447
/**
415448
* Generate base branch url consisting of server/action/organization/dbid/branchid
416449
*/

lib/woqlClient.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,32 @@ WOQLClient.prototype.optimize_system = function() {
608608
return this.dispatch(CONST.OPTIMIZE_SYSTEM, this.connectionConfig.optimizeSystemUrl())
609609
}
610610

611+
/**
612+
* Optimize db meta
613+
* @returns {Promise}
614+
*/
615+
WOQLClient.prototype.optimize_meta = function() {
616+
return this.dispatch(CONST.OPTIMIZE_SYSTEM, this.connectionConfig.optimizeMetaUrl())
617+
}
618+
619+
/**
620+
* Optimize db commits
621+
* @returns {Promise}
622+
*/
623+
WOQLClient.prototype.optimize_commit = function() {
624+
return this.dispatch(CONST.OPTIMIZE_SYSTEM, this.connectionConfig.optimizeCommitUrl())
625+
}
626+
627+
/**
628+
* Optimize db branch
629+
* @param {string} branch_id - local identifier of the new branch
630+
* @returns {Promise}
631+
*/
632+
WOQLClient.prototype.optimize_branch = function(branch_id) {
633+
console.log("this.connectionConfig.optimizeBranchUrl(branch_id)",this.connectionConfig.optimizeBranchUrl(branch_id))
634+
return this.dispatch(CONST.OPTIMIZE_SYSTEM, this.connectionConfig.optimizeBranchUrl(branch_id))
635+
}
636+
611637

612638
/**
613639
* deletes a branch from database

0 commit comments

Comments
 (0)