optimizations

This commit is contained in:
Thomas Rudin 2019-02-15 17:53:32 +01:00
parent 91aa1b6481
commit dabc52fbe8
6 changed files with 15 additions and 15 deletions

View File

@ -25,7 +25,5 @@ type DBAccessor interface {
FindBlocksByMtime(gtmtime int64, limit int) ([]*Block, error)
FindNextInitialBlocks(s settings.Settings, layers []*layer.Layer, limit int) (*InitialBlocksResult, error)
CountBlocks(frommtime, tomtime int64) (int, error)
GetBlock(pos *coords.MapBlockCoords) (*Block, error)
}

View File

@ -1,11 +1,12 @@
package sqlite
import (
_ "github.com/mattn/go-sqlite3"
"mapserver/coords"
"mapserver/db"
"mapserver/layer"
"mapserver/settings"
_ "github.com/mattn/go-sqlite3"
)
const (
@ -17,8 +18,7 @@ const (
const getLastBlockQuery = `
select pos,data,mtime
from blocks b
where b.mtime = 0
and b.pos > ?
where b.pos > ?
order by b.pos asc, b.mtime asc
limit ?
`
@ -33,7 +33,7 @@ func (this *Sqlite3Accessor) FindNextInitialBlocks(s settings.Settings, layers [
totallegacycount := s.GetInt64(SETTING_TOTAL_LEGACY_COUNT, -1)
if totallegacycount == -1 {
//Query from db
totallegacycount, err := this.CountBlocks(0, 0)
totallegacycount, err := this.CountBlocks()
if err != nil {
panic(err)

View File

@ -9,7 +9,7 @@ limit ?
`
const countBlocksQuery = `
select count(*) from blocks b where b.mtime >= ? and b.mtime <= ?
select count(*) from blocks b
`
const getBlockQuery = `

View File

@ -2,12 +2,13 @@ package sqlite
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
"github.com/sirupsen/logrus"
"mapserver/coords"
"mapserver/db"
"mapserver/vfs"
"time"
_ "github.com/mattn/go-sqlite3"
"github.com/sirupsen/logrus"
)
/*
@ -83,8 +84,8 @@ func (this *Sqlite3Accessor) FindBlocksByMtime(gtmtime int64, limit int) ([]*db.
return blocks, nil
}
func (db *Sqlite3Accessor) CountBlocks(frommtime, tomtime int64) (int, error) {
rows, err := db.db.Query(countBlocksQuery, frommtime, tomtime)
func (db *Sqlite3Accessor) CountBlocks() (int, error) {
rows, err := db.db.Query(countBlocksQuery)
if err != nil {
return 0, err
}

View File

@ -1,12 +1,13 @@
package sqlite
import (
_ "github.com/mattn/go-sqlite3"
"io/ioutil"
"mapserver/coords"
"mapserver/testutils"
"os"
"testing"
_ "github.com/mattn/go-sqlite3"
)
func TestMigrateEmpty(t *testing.T) {
@ -93,7 +94,7 @@ func TestMigrateAndQueryCount(t *testing.T) {
panic(err)
}
count, err := a.CountBlocks(0, 0)
count, err := a.CountBlocks()
if err != nil {
panic(err)
}

View File

@ -23,9 +23,9 @@ var LuacontrollerOverlay = AbstractIconOverlay.extend({
getIcon: function(ctrl){
if (ctrl.burnt)
return LuacontrollerIcon;
else
return LuacontrollerBurntIcon;
else
return LuacontrollerIcon;
},
createPopup: function(ctrl){