diff --git a/build-nowebsockets.bat b/build-nowebsockets.bat index 1645a1d8..a23d6e38 100644 --- a/build-nowebsockets.bat +++ b/build-nowebsockets.bat @@ -1,4 +1,10 @@ @echo off +rem TODO: Make these deletes a little less noisy +del "template_*.go" +del "gen_*.go" +del "tmpl_client/template_*.go" +del "gosora.exe" + echo Generating the dynamic code go generate if %errorlevel% neq 0 ( diff --git a/build.bat b/build.bat index f82b5899..cf435db3 100644 --- a/build.bat +++ b/build.bat @@ -1,4 +1,10 @@ @echo off +rem TODO: Make these deletes a little less noisy +del "template_*.go" +del "gen_*.go" +del "tmpl_client/template_*.go" +del "gosora.exe" + echo Generating the dynamic code go generate if %errorlevel% neq 0 ( diff --git a/common/null_user_cache.go b/common/null_user_cache.go index 30f3b5c3..46415f54 100644 --- a/common/null_user_cache.go +++ b/common/null_user_cache.go @@ -12,8 +12,8 @@ func (mus *NullUserCache) Get(id int) (*User, error) { return nil, ErrNoRows } -func (mus *NullUserCache) BulkGet(ids []int) (list []*User) { - return list +func (mus *NullUserCache) BulkGet(_ []int) (list []*User) { + return nil } func (mus *NullUserCache) GetUnsafe(id int) (*User, error) { diff --git a/common/topic.go b/common/topic.go index 3b45141d..2830fdc4 100644 --- a/common/topic.go +++ b/common/topic.go @@ -380,7 +380,7 @@ func copyTopicToTopicUser(topic *Topic, user *User) (tu TopicUser) { // For use in tests and for generating blank topics for forums which don't have a last poster func BlankTopic() *Topic { - return &Topic{ID: 0, Title: ""} + return new(Topic) } func BuildTopicURL(slug string, tid int) string { diff --git a/common/user.go b/common/user.go index 71194ffb..fcb5f00a 100644 --- a/common/user.go +++ b/common/user.go @@ -392,7 +392,7 @@ func wordsToScore(wcount int, topic bool) (score int) { // For use in tests and to help generate dummy users for forums which don't have last posters func BlankUser() *User { - return &User{ID: 0, Name: ""} + return new(User) } // TODO: Write unit tests for this diff --git a/common/user_store.go b/common/user_store.go index 4de39f94..fae83ac7 100644 --- a/common/user_store.go +++ b/common/user_store.go @@ -129,14 +129,16 @@ func (mus *DefaultUserStore) BulkGetMap(ids []int) (list map[int]*User, err erro var stillHere []int sliceList := mus.cache.BulkGet(ids) - for i, sliceItem := range sliceList { - if sliceItem != nil { - list[sliceItem.ID] = sliceItem - } else { - stillHere = append(stillHere, ids[i]) + if len(sliceList) > 0 { + for i, sliceItem := range sliceList { + if sliceItem != nil { + list[sliceItem.ID] = sliceItem + } else { + stillHere = append(stillHere, ids[i]) + } } + ids = stillHere } - ids = stillHere // If every user is in the cache, then return immediately if len(ids) == 0 { diff --git a/general_test.go b/general_test.go index 6519d2be..8ec587ce 100644 --- a/general_test.go +++ b/general_test.go @@ -45,7 +45,11 @@ func ResetTables() (err error) { } func gloinit() (err error) { + // TODO: Make these configurable via flags to the go test command common.Dev.DebugMode = false + common.Dev.SuperDebug = false + common.Dev.TemplateDebug = false + qgen.LogPrepares = false //nogrouplog = true common.StartTime = time.Now() diff --git a/langs/english.json b/langs/english.json index 4313c88b..716a06d7 100644 --- a/langs/english.json +++ b/langs/english.json @@ -662,7 +662,7 @@ "panel_pages_head":"Page Manager", "panel_pages_edit_button_aria":"Edit Page", "panel_pages_delete_button_aria":"Delete Page", - "panel_pages_no_pages":"There aren't any pages.", + "panel_pages_no_pages":"You don't have any pages yet.", "panel_pages_create_head":"Create Page", "panel_pages_create_name":"Name", "panel_pages_create_name_placeholder":"faq", diff --git a/misc_test.go b/misc_test.go index 22ec756d..ab83be82 100644 --- a/misc_test.go +++ b/misc_test.go @@ -124,11 +124,7 @@ func userStoreTest(t *testing.T, newUserID int) { expect(t, isCacheLengthZero(ucache), fmt.Sprintf("User cache length should be 0, not %d", cacheLength(ucache))) userList, _ = common.Users.BulkGetMap([]int{1}) - if len(userList) == 0 { - t.Error("The returned map is empty for UID #1") - } else if len(userList) > 1 { - t.Error("Too many results were returned for UID #1") - } + expect(t, len(userList) == 1, fmt.Sprintf("Returned map should have one result (UID #1), not %d", len(userList))) user, ok := userList[1] if !ok { @@ -620,7 +616,7 @@ func TestForumStore(t *testing.T) { forum, err = common.Forums.Get(3) recordMustExist(t, err, "Couldn't find FID #3") - expect(t, forum.ID == 2, fmt.Sprintf("The FID should be 3 not %d", forum.ID)) + expect(t, forum.ID == 3, fmt.Sprintf("The FID should be 3 not %d", forum.ID)) expect(t, forum.Name == "Test Forum", fmt.Sprintf("The name of the forum should be 'Test Forum' not '%s'", forum.Name)) expect(t, forum.Active, fmt.Sprintf("The test forum should be active")) expect(t, forum.Desc == "", fmt.Sprintf("The forum description should be blank not '%s'", forum.Desc)) diff --git a/query_gen/lib/accumulator.go b/query_gen/lib/accumulator.go index 11770ace..f9c21c91 100644 --- a/query_gen/lib/accumulator.go +++ b/query_gen/lib/accumulator.go @@ -6,6 +6,8 @@ import ( "log" ) +var LogPrepares = true + type Accumulator struct { conn *sql.DB adapter Adapter @@ -43,7 +45,9 @@ func (build *Accumulator) recordError(err error) { } func (build *Accumulator) prepare(res string, err error) *sql.Stmt { - log.Print("res: ", res) + if LogPrepares { + log.Print("res: ", res) + } if err != nil { build.recordError(err) return nil diff --git a/run-nowebsockets.bat b/run-nowebsockets.bat index 5699bb4f..c176f39d 100644 --- a/run-nowebsockets.bat +++ b/run-nowebsockets.bat @@ -1,4 +1,10 @@ @echo off +rem TODO: Make these deletes a little less noisy +del "template_*.go" +del "gen_*.go" +del "tmpl_client/template_*.go" +del "gosora.exe" + echo Generating the dynamic code go generate if %errorlevel% neq 0 ( diff --git a/run.bat b/run.bat index ab74ac2b..b7df9533 100644 --- a/run.bat +++ b/run.bat @@ -1,4 +1,10 @@ @echo off +rem TODO: Make these deletes a little less noisy +del "template_*.go" +del "gen_*.go" +del "tmpl_client/template_*.go" +del "gosora.exe" + echo Generating the dynamic code go generate if %errorlevel% neq 0 ( diff --git a/run_mssql.bat b/run_mssql.bat index ff6bb4a3..bbaf43d7 100644 --- a/run_mssql.bat +++ b/run_mssql.bat @@ -1,4 +1,10 @@ @echo off +rem TODO: Make these deletes a little less noisy +del "template_*.go" +del "gen_*.go" +del "tmpl_client/template_*.go" +del "gosora.exe" + echo Generating the dynamic code go generate if %errorlevel% neq 0 ( diff --git a/run_tests.bat b/run_tests.bat index d3c86d9c..f94f7698 100644 --- a/run_tests.bat +++ b/run_tests.bat @@ -1,4 +1,10 @@ @echo off +rem TODO: Make these deletes a little less noisy +del "template_*.go" +del "gen_*.go" +del "tmpl_client/template_*.go" +del "gosora.exe" + echo Generating the dynamic code go generate if %errorlevel% neq 0 ( diff --git a/run_tests_mssql.bat b/run_tests_mssql.bat index 119319e9..876ad8c2 100644 --- a/run_tests_mssql.bat +++ b/run_tests_mssql.bat @@ -1,4 +1,10 @@ @echo off +rem TODO: Make these deletes a little less noisy +del "template_*.go" +del "gen_*.go" +del "tmpl_client/template_*.go" +del "gosora.exe" + echo Generating the dynamic code go generate if %errorlevel% neq 0 (