Skip to content

Commit

Permalink
extends TTL of plateform connection to optimize performance of last c…
Browse files Browse the repository at this point in the history
…onnection fetching
  • Loading branch information
geektortoise committed Feb 27, 2020
1 parent 611fc99 commit b5fc673
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion grails-app/domain/be/cytomine/social/LastConnection.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ class LastConnection extends CytomineDomain{
static mapping = {
id(generator: 'assigned', unique: true)
sort "id"
compoundIndex date:1, indexAttributes:['expireAfterSeconds':60]
compoundIndex date:2, indexAttributes:['expireAfterSeconds':300]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ class ProjectService extends ModelService {
def group2 = [$group : [_id : '$_id.project', "users" :[$sum:1]]]
def result;

result = db.persistentConnection.aggregate(
result = db.lastConnection.aggregate(
match,
group1,
group2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class BootstrapOldVersionService {
void initv2_1_0() {
log.info "2.1.0"
new Sql(dataSource).executeUpdate("ALTER TABLE project ADD COLUMN IF NOT EXISTS are_images_downloadable BOOLEAN DEFAULT FALSE;")
noSQLCollectionService.dropIndex("lastConnection", "date_1")
}

void initv2_0_0() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ package be.cytomine.utils.database.mongodb
* limitations under the License.
*/

/**
* Created by IntelliJ IDEA.
* User: lrollus
* Date: 7/07/11
* Time: 15:16
* Service used to create index at the application begining
*/
import com.mongodb.CommandFailureException

class NoSQLCollectionService {

def sessionFactory
Expand Down Expand Up @@ -52,5 +47,14 @@ class NoSQLCollectionService {
db.persistentUserPosition.drop()
}

public def dropIndex(String collection, String name) {
log.info "Drop index $name from $collection collection"
def db = mongo.getDB(getDatabaseName())
try {
db."${collection}".dropIndex(name)
} catch(CommandFailureException e){
log.error (collection+" : "+e.message)
}
}

}

0 comments on commit b5fc673

Please sign in to comment.