Skip to content

Commit

Permalink
removed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bankole7782 committed Jul 17, 2020
1 parent 6d6e9bb commit f319b48
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
21 changes: 0 additions & 21 deletions flaarum_shared/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ import (
)


var (
STOP_WORDS []string
)


const (
BROWSER_DATE_FORMAT = "2006-01-02"
BROWSER_DATETIME_FORMAT = "2006-01-02T15:04"
Expand All @@ -32,22 +27,6 @@ const (
)


func init() {
// load stop words once
stopWordsJsonPath := G("english-stopwords.json")
jsonBytes, err := ioutil.ReadFile(stopWordsJsonPath)
if err != nil {
panic(err)
}
stopWordsList := make([]string, 0)
err = json.Unmarshal(jsonBytes, &stopWordsList)
if err != nil {
panic(err)
}
STOP_WORDS = stopWordsList
}


func DoesPathExists(p string) bool {
if _, err := os.Stat(p); os.IsNotExist(err) {
return false
Expand Down
14 changes: 14 additions & 0 deletions store/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

var projsMutex *sync.RWMutex // for projects and tables (table data uses different mutexes) creation, editing, deletion
var tablesMutexes map[string]*sync.RWMutex
var STOP_WORDS []string

func init() {
dataPath, err := GetDataPath()
Expand Down Expand Up @@ -58,6 +59,19 @@ func init() {
panic(err)
}
}

// load stop words once
stopWordsJsonPath := flaarum_shared.G("english-stopwords.json")
jsonBytes, err := ioutil.ReadFile(stopWordsJsonPath)
if err != nil {
panic(err)
}
stopWordsList := make([]string, 0)
err = json.Unmarshal(jsonBytes, &stopWordsList)
if err != nil {
panic(err)
}
STOP_WORDS = stopWordsList
}


Expand Down
12 changes: 6 additions & 6 deletions store/searches.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ func innerSearch(projName, stmt string) (*[]map[string]string, error) {
if word == "" {
continue
}
if flaarum_shared.FindIn(flaarum_shared.STOP_WORDS, word) != -1 {
if flaarum_shared.FindIn(STOP_WORDS, word) != -1 {
continue
}

Expand Down Expand Up @@ -1003,7 +1003,7 @@ func innerSearch(projName, stmt string) (*[]map[string]string, error) {
if word == "" {
continue
}
if flaarum_shared.FindIn(flaarum_shared.STOP_WORDS, word) != -1 {
if flaarum_shared.FindIn(STOP_WORDS, word) != -1 {
continue
}
dirFIs, err := ioutil.ReadDir(filepath.Join(otherTablePath, "tindexes", otherFieldName, word))
Expand Down Expand Up @@ -1040,7 +1040,7 @@ func innerSearch(projName, stmt string) (*[]map[string]string, error) {
if word == "" {
continue
}
if flaarum_shared.FindIn(flaarum_shared.STOP_WORDS, word) != -1 {
if flaarum_shared.FindIn(STOP_WORDS, word) != -1 {
continue
}
dirFIs, err := ioutil.ReadDir(filepath.Join(otherTablePath, "tindexes", otherFieldName, word))
Expand Down Expand Up @@ -1090,7 +1090,7 @@ func innerSearch(projName, stmt string) (*[]map[string]string, error) {
if word == "" {
continue
}
if flaarum_shared.FindIn(flaarum_shared.STOP_WORDS, word) != -1 {
if flaarum_shared.FindIn(STOP_WORDS, word) != -1 {
continue
}

Expand Down Expand Up @@ -1134,7 +1134,7 @@ func innerSearch(projName, stmt string) (*[]map[string]string, error) {
if word == "" {
continue
}
if flaarum_shared.FindIn(flaarum_shared.STOP_WORDS, word) != -1 {
if flaarum_shared.FindIn(STOP_WORDS, word) != -1 {
continue
}
dirFIs, err := ioutil.ReadDir(filepath.Join(tablePath, "tindexes", whereStruct.FieldName, word))
Expand Down Expand Up @@ -1171,7 +1171,7 @@ func innerSearch(projName, stmt string) (*[]map[string]string, error) {
if word == "" {
continue
}
if flaarum_shared.FindIn(flaarum_shared.STOP_WORDS, word) != -1 {
if flaarum_shared.FindIn(STOP_WORDS, word) != -1 {
continue
}
dirFIs, err := ioutil.ReadDir(filepath.Join(tablePath, "tindexes", whereStruct.FieldName, word))
Expand Down
19 changes: 18 additions & 1 deletion tindexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ import (
"os"
"sync"
"github.com/microcosm-cc/bluemonday"
"encoding/json"
)

var (
mutexesMap map[string]*sync.Mutex
debugMode bool
STOP_WORDS []string
)


func init() {
mutexesMap = make(map[string]*sync.Mutex)

Expand All @@ -31,6 +34,20 @@ func init() {
if debug == "true" || debug == "t" {
debugMode = true
}

// load stop words once
stopWordsJsonPath := flaarum_shared.G("english-stopwords.json")
jsonBytes, err := ioutil.ReadFile(stopWordsJsonPath)
if err != nil {
panic(err)
}
stopWordsList := make([]string, 0)
err = json.Unmarshal(jsonBytes, &stopWordsList)
if err != nil {
panic(err)
}
STOP_WORDS = stopWordsList

}


Expand Down Expand Up @@ -144,7 +161,7 @@ func doIndex(textPath string) {
if word == "" {
continue
}
if flaarum_shared.FindIn(flaarum_shared.STOP_WORDS, word) != -1 {
if flaarum_shared.FindIn(STOP_WORDS, word) != -1 {
continue
}

Expand Down

0 comments on commit f319b48

Please sign in to comment.