mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
Compare commits
5 Commits
844233e70d
...
45beaced89
Author | SHA1 | Date | |
---|---|---|---|
45beaced89 | |||
af81f66f25 | |||
ff1f6e7340 | |||
0a88a65846 | |||
316929db33 |
8
go.mod
8
go.mod
@@ -11,13 +11,15 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/blevesearch/bleve v1.0.14
|
||||||
github.com/chai2010/webp v1.4.0
|
github.com/chai2010/webp v1.4.0
|
||||||
|
github.com/disintegration/imaging v1.6.2
|
||||||
|
github.com/stretchr/testify v1.11.1
|
||||||
gorm.io/driver/mysql v1.5.7
|
gorm.io/driver/mysql v1.5.7
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/RoaringBitmap/roaring v0.4.23 // indirect
|
github.com/RoaringBitmap/roaring v0.4.23 // indirect
|
||||||
github.com/blevesearch/bleve v1.0.14 // indirect
|
|
||||||
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect
|
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect
|
||||||
github.com/blevesearch/mmap-go v1.0.2 // indirect
|
github.com/blevesearch/mmap-go v1.0.2 // indirect
|
||||||
github.com/blevesearch/segment v0.9.0 // indirect
|
github.com/blevesearch/segment v0.9.0 // indirect
|
||||||
@@ -28,15 +30,17 @@ require (
|
|||||||
github.com/blevesearch/zap/v14 v14.0.5 // indirect
|
github.com/blevesearch/zap/v14 v14.0.5 // indirect
|
||||||
github.com/blevesearch/zap/v15 v15.0.3 // indirect
|
github.com/blevesearch/zap/v15 v15.0.3 // indirect
|
||||||
github.com/couchbase/vellum v1.0.2 // indirect
|
github.com/couchbase/vellum v1.0.2 // indirect
|
||||||
github.com/disintegration/imaging v1.6.2 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 // indirect
|
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||||
github.com/golang/protobuf v1.3.2 // indirect
|
github.com/golang/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/snappy v0.0.1 // indirect
|
github.com/golang/snappy v0.0.1 // indirect
|
||||||
github.com/mschoch/smat v0.2.0 // indirect
|
github.com/mschoch/smat v0.2.0 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/steveyen/gtreap v0.1.0 // indirect
|
github.com/steveyen/gtreap v0.1.0 // indirect
|
||||||
github.com/willf/bitset v1.1.10 // indirect
|
github.com/willf/bitset v1.1.10 // indirect
|
||||||
go.etcd.io/bbolt v1.3.5 // indirect
|
go.etcd.io/bbolt v1.3.5 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
16
go.sum
16
go.sum
@@ -6,6 +6,7 @@ github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOL
|
|||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
github.com/blevesearch/bleve v1.0.14 h1:Q8r+fHTt35jtGXJUM0ULwM3Tzg+MRfyai4ZkWDy2xO4=
|
github.com/blevesearch/bleve v1.0.14 h1:Q8r+fHTt35jtGXJUM0ULwM3Tzg+MRfyai4ZkWDy2xO4=
|
||||||
github.com/blevesearch/bleve v1.0.14/go.mod h1:e/LJTr+E7EaoVdkQZTfoz7dt4KoDNvDbLb8MSKuNTLQ=
|
github.com/blevesearch/bleve v1.0.14/go.mod h1:e/LJTr+E7EaoVdkQZTfoz7dt4KoDNvDbLb8MSKuNTLQ=
|
||||||
|
github.com/blevesearch/blevex v1.0.0 h1:pnilj2Qi3YSEGdWgLj1Pn9Io7ukfXPoQcpAI1Bv8n/o=
|
||||||
github.com/blevesearch/blevex v1.0.0/go.mod h1:2rNVqoG2BZI8t1/P1awgTKnGlx5MP9ZbtEciQaNhswc=
|
github.com/blevesearch/blevex v1.0.0/go.mod h1:2rNVqoG2BZI8t1/P1awgTKnGlx5MP9ZbtEciQaNhswc=
|
||||||
github.com/blevesearch/cld2 v0.0.0-20200327141045-8b5f551d37f5/go.mod h1:PN0QNTLs9+j1bKy3d/GB/59wsNBFC4sWLWG3k69lWbc=
|
github.com/blevesearch/cld2 v0.0.0-20200327141045-8b5f551d37f5/go.mod h1:PN0QNTLs9+j1bKy3d/GB/59wsNBFC4sWLWG3k69lWbc=
|
||||||
github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo=
|
github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo=
|
||||||
@@ -36,6 +37,7 @@ github.com/couchbase/moss v0.1.0/go.mod h1:9MaHIaRuy9pvLPUJxB8sh8OrLfyDczECVL37g
|
|||||||
github.com/couchbase/vellum v1.0.2 h1:BrbP0NKiyDdndMPec8Jjhy0U47CZ0Lgx3xUC2r9rZqw=
|
github.com/couchbase/vellum v1.0.2 h1:BrbP0NKiyDdndMPec8Jjhy0U47CZ0Lgx3xUC2r9rZqw=
|
||||||
github.com/couchbase/vellum v1.0.2/go.mod h1:FcwrEivFpNi24R3jLOs3n+fs5RnuQnQqCLBJ1uAg1W4=
|
github.com/couchbase/vellum v1.0.2/go.mod h1:FcwrEivFpNi24R3jLOs3n+fs5RnuQnQqCLBJ1uAg1W4=
|
||||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||||
|
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d h1:SwD98825d6bdB+pEuTxWOXiSjBrHdOl/UVp75eI7JT8=
|
||||||
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d/go.mod h1:URriBxXwVq5ijiJ12C7iIZqlA69nTlI+LgI6/pwftG8=
|
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d/go.mod h1:URriBxXwVq5ijiJ12C7iIZqlA69nTlI+LgI6/pwftG8=
|
||||||
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
|
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
|
||||||
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc=
|
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc=
|
||||||
@@ -54,6 +56,7 @@ github.com/fxamacker/cbor/v2 v2.8.0 h1:fFtUGXUzXPHTIUdne5+zzMPTfffl3RD5qYnkY40vt
|
|||||||
github.com/fxamacker/cbor/v2 v2.8.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
github.com/fxamacker/cbor/v2 v2.8.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
||||||
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4=
|
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4=
|
||||||
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
|
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
|
||||||
|
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8=
|
||||||
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
|
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
|
||||||
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||||
@@ -79,7 +82,6 @@ github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b h1:EY/KpStFl60
|
|||||||
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
|
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw=
|
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
@@ -91,6 +93,7 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
|||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=
|
||||||
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
|
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
@@ -149,10 +152,12 @@ github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
|
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
github.com/tebeka/snowball v0.4.2/go.mod h1:4IfL14h1lvwZcp1sfXuuc7/7yCsvVffTWxWxCLfFpYg=
|
github.com/tebeka/snowball v0.4.2/go.mod h1:4IfL14h1lvwZcp1sfXuuc7/7yCsvVffTWxWxCLfFpYg=
|
||||||
|
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok=
|
||||||
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
|
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
|
||||||
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
github.com/tinylib/msgp v1.2.5 h1:WeQg1whrXRFiZusidTQqzETkRpGjFjcIhW6uqWH09po=
|
github.com/tinylib/msgp v1.2.5 h1:WeQg1whrXRFiZusidTQqzETkRpGjFjcIhW6uqWH09po=
|
||||||
@@ -176,8 +181,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
|||||||
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
|
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
|
||||||
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
|
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
|
||||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/image v0.27.0 h1:C8gA4oWU/tKkdCfYT6T2u4faJu3MeNS5O8UPWlPF61w=
|
|
||||||
golang.org/x/image v0.27.0/go.mod h1:xbdrClrAUway1MUTEZDq9mz/UpRwYAkFFNUslZtcB+g=
|
|
||||||
golang.org/x/image v0.28.0 h1:gdem5JW1OLS4FbkWgLO+7ZeFzYtL3xClb97GaUzYMFE=
|
golang.org/x/image v0.28.0 h1:gdem5JW1OLS4FbkWgLO+7ZeFzYtL3xClb97GaUzYMFE=
|
||||||
golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY=
|
golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@@ -195,11 +198,10 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
||||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
|
||||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
|
||||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
@@ -70,3 +70,11 @@ func GetDB() *gorm.DB {
|
|||||||
func IsReady() bool {
|
func IsReady() bool {
|
||||||
return ready
|
return ready
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Close() error {
|
||||||
|
sqlDB, err := db.DB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return sqlDB.Close()
|
||||||
|
}
|
||||||
|
@@ -19,7 +19,7 @@ func CreateTag(tag string) (model.Tag, error) {
|
|||||||
if err := db.Create(&t).Error; err != nil {
|
if err := db.Create(&t).Error; err != nil {
|
||||||
return model.Tag{}, err
|
return model.Tag{}, err
|
||||||
}
|
}
|
||||||
return t, nil
|
return GetTagByID(t.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTagWithType(tag string, tagType string) (model.Tag, error) {
|
func CreateTagWithType(tag string, tagType string) (model.Tag, error) {
|
||||||
@@ -82,13 +82,34 @@ func GetTagByName(name string) (model.Tag, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetTagInfo(id uint, description string, aliasOf *uint, tagType string) error {
|
func SetTagInfo(id uint, description string, aliasOf *uint, tagType string) error {
|
||||||
|
// Get the tag information
|
||||||
old, err := GetTagByID(id)
|
old, err := GetTagByID(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if aliasOf != nil && len(old.Aliases) > 0 {
|
|
||||||
return model.NewRequestError("Tag already has aliases, cannot set alias_of")
|
// If the alias tag is an alias itself, we need to find its root tag
|
||||||
|
if aliasOf != nil {
|
||||||
|
tag, err := GetTagByID(*aliasOf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if tag.AliasOf != nil {
|
||||||
|
aliasOf = tag.AliasOf
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the tag has aliases, we need to update their alias_of field
|
||||||
|
if aliasOf != nil && len(old.Aliases) > 0 {
|
||||||
|
for _, alias := range old.Aliases {
|
||||||
|
err := db.Model(&alias).Update("alias_of", *aliasOf).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the tag information
|
||||||
t := model.Tag{Model: gorm.Model{
|
t := model.Tag{Model: gorm.Model{
|
||||||
ID: id,
|
ID: id,
|
||||||
}, Description: description, Type: tagType, AliasOf: aliasOf}
|
}, Description: description, Type: tagType, AliasOf: aliasOf}
|
||||||
@@ -113,24 +134,51 @@ func ListTags() ([]model.Tag, error) {
|
|||||||
|
|
||||||
// SetTagAlias sets a tag with the given ID having the given alias.
|
// SetTagAlias sets a tag with the given ID having the given alias.
|
||||||
func SetTagAlias(tagID uint, alias string) error {
|
func SetTagAlias(tagID uint, alias string) error {
|
||||||
// Set a tag as an alias of another tag
|
exists, err := ExistsTagByID(tagID)
|
||||||
var t model.Tag
|
if err != nil {
|
||||||
if err := db.Where("name = ?", alias).First(&t).Error; err != nil {
|
return err
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
}
|
||||||
// create
|
if !exists {
|
||||||
newTag, err := CreateTag(alias)
|
return model.NewNotFoundError("Tag not found")
|
||||||
if err != nil {
|
}
|
||||||
return err
|
|
||||||
}
|
exists, err = ExistsTag(alias)
|
||||||
t = newTag
|
if err != nil {
|
||||||
} else {
|
return err
|
||||||
|
}
|
||||||
|
if !exists {
|
||||||
|
// Create the alias tag if it does not exist
|
||||||
|
_, err := CreateTag(alias)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.ID == tagID {
|
// Get the alias tag
|
||||||
return model.NewRequestError("Tag cannot be an alias of itself")
|
tag, err := GetTagByName(alias)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return db.Model(&t).Update("alias_of", tagID).Error
|
// If the alias tag is an alias itself, we need to find its root tag
|
||||||
|
if tag.AliasOf != nil {
|
||||||
|
tag, err = GetTagByID(*tag.AliasOf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the tag has aliases, we need to update their alias_of field
|
||||||
|
for _, alias := range tag.Aliases {
|
||||||
|
err := db.Model(&alias).Update("alias_of", tagID).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tag.Aliases = nil
|
||||||
|
// A tag cannot be an alias of itself
|
||||||
|
if tag.ID == tagID {
|
||||||
|
return model.NewRequestError("A tag cannot be an alias of itself")
|
||||||
|
}
|
||||||
|
// Set the alias_of field of the tag
|
||||||
|
return db.Model(&tag).Update("alias_of", tagID).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveTagAliasOf sets a tag is an independent tag, removing its alias relationship.
|
// RemoveTagAliasOf sets a tag is an independent tag, removing its alias relationship.
|
||||||
@@ -180,3 +228,11 @@ func ExistsTag(name string) (bool, error) {
|
|||||||
}
|
}
|
||||||
return count > 0, nil
|
return count > 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExistsTagByID(id uint) (bool, error) {
|
||||||
|
var count int64
|
||||||
|
if err := db.Model(&model.Tag{}).Where("id = ?", id).Count(&count).Error; err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return count > 0, nil
|
||||||
|
}
|
||||||
|
109
server/dao/tag_test.go
Normal file
109
server/dao/tag_test.go
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTag(t *testing.T) {
|
||||||
|
// Create tags
|
||||||
|
tag1, err := CreateTag("test1")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag2, err := CreateTag("test2")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag3, err := CreateTagWithType("test3", "type1")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
// Get tag by ID
|
||||||
|
fetchedTag, err := GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, tag1.Name, fetchedTag.Name)
|
||||||
|
|
||||||
|
// Get tag by Name
|
||||||
|
fetchedTag, err = GetTagByName(tag2.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, tag2.ID, fetchedTag.ID)
|
||||||
|
|
||||||
|
// Search tags
|
||||||
|
tags, err := SearchTag("test", true)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.GreaterOrEqual(t, len(tags), 3)
|
||||||
|
|
||||||
|
// Update tag
|
||||||
|
err = SetTagInfo(tag1.ID, "updated description", nil, "updated type")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
updatedTag, err := GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, "updated description", updatedTag.Description)
|
||||||
|
assert.Equal(t, "updated type", updatedTag.Type)
|
||||||
|
|
||||||
|
// Set tag alias
|
||||||
|
err = SetTagAlias(tag1.ID, tag2.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagAlias(tag1.ID, tag3.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagAlias(tag1.ID, "test4")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag4, err := GetTagByName("test4")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag1, err = GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
aliasesIDs := []uint{}
|
||||||
|
for _, alias := range tag1.Aliases {
|
||||||
|
aliasesIDs = append(aliasesIDs, alias.ID)
|
||||||
|
}
|
||||||
|
assert.Equal(t, []uint{tag2.ID, tag3.ID, tag4.ID}, aliasesIDs)
|
||||||
|
|
||||||
|
// let a tag which has alias point to another tag
|
||||||
|
tag5, err := CreateTag("test5")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagAlias(tag5.ID, tag1.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag1, err = GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag2, err = GetTagByID(tag2.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag3, err = GetTagByID(tag3.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag4, err = GetTagByID(tag4.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag5, err = GetTagByID(tag5.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Empty(t, tag1.Aliases)
|
||||||
|
assert.Equal(t, &tag5.ID, tag1.AliasOf)
|
||||||
|
assert.Equal(t, &tag5.ID, tag2.AliasOf)
|
||||||
|
assert.Equal(t, &tag5.ID, tag3.AliasOf)
|
||||||
|
assert.Equal(t, &tag5.ID, tag4.AliasOf)
|
||||||
|
assert.Nil(t, tag5.AliasOf)
|
||||||
|
|
||||||
|
// Same operation as above, but using `SetTagInfo`
|
||||||
|
tag6, err := CreateTag("test6")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagInfo(tag5.ID, "", &tag6.ID, "")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag1, err = GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag2, err = GetTagByID(tag2.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag3, err = GetTagByID(tag3.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag4, err = GetTagByID(tag4.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag5, err = GetTagByID(tag5.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag6, err = GetTagByID(tag6.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, &tag6.ID, tag1.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag2.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag3.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag4.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag5.AliasOf)
|
||||||
|
assert.Empty(t, tag5.Aliases)
|
||||||
|
assert.Nil(t, tag6.AliasOf)
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
_ = Close()
|
||||||
|
_ = os.Remove("test.db")
|
||||||
|
}
|
@@ -101,3 +101,14 @@ func SearchResource(keyword string) ([]uint, error) {
|
|||||||
|
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsStopWord(word string) bool {
|
||||||
|
mapping := bleve.NewIndexMapping()
|
||||||
|
analyzerName := mapping.DefaultAnalyzer
|
||||||
|
analyzer := mapping.AnalyzerNamed(analyzerName)
|
||||||
|
if analyzer == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
tokens := analyzer.Analyze([]byte(word))
|
||||||
|
return len(tokens) == 0
|
||||||
|
}
|
||||||
|
185
server/search/search_test.go
Normal file
185
server/search/search_test.go
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
package search
|
||||||
|
|
||||||
|
import (
|
||||||
|
"nysoure/server/dao"
|
||||||
|
"nysoure/server/model"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/blevesearch/bleve"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
err := index.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
_ = os.RemoveAll("search_test.bleve")
|
||||||
|
mapper := bleve.NewIndexMapping()
|
||||||
|
index, err = bleve.New("search_test.bleve", mapper)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TearDown() {
|
||||||
|
err := index.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
dao.Close()
|
||||||
|
os.RemoveAll("search_test.bleve")
|
||||||
|
os.Remove("test.db")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSearchResource(t *testing.T) {
|
||||||
|
Init()
|
||||||
|
defer TearDown()
|
||||||
|
|
||||||
|
resources := []model.Resource{
|
||||||
|
// normal cases
|
||||||
|
{Model: gorm.Model{ID: 1}, Title: "The Great Adventure", AlternativeTitles: []string{"Adventure Time", "The Big Adventure"}},
|
||||||
|
{Model: gorm.Model{ID: 2}, Title: "Mystery of the Lost City", AlternativeTitles: []string{"Lost City Chronicles"}},
|
||||||
|
{Model: gorm.Model{ID: 3}, Title: "Romance in Paris", AlternativeTitles: []string{"Love in Paris", "Parisian Romance"}},
|
||||||
|
{Model: gorm.Model{ID: 4}, Title: "Sci-Fi Extravaganza", AlternativeTitles: []string{"Future World", "Sci-Fi Saga"}},
|
||||||
|
{Model: gorm.Model{ID: 5}, Title: "Comedy Nights", AlternativeTitles: []string{"Laugh Out Loud", "Comedy Central"}},
|
||||||
|
// With special characters
|
||||||
|
{Model: gorm.Model{ID: 6}, Title: "Action & Adventure", AlternativeTitles: []string{"Action-Packed", "Adventure Time!"}},
|
||||||
|
{Model: gorm.Model{ID: 7}, Title: "Horror: The Awakening", AlternativeTitles: []string{"Scary Movie", "Horror Nights"}},
|
||||||
|
{Model: gorm.Model{ID: 8}, Title: "Drama @ Home", AlternativeTitles: []string{"Home Stories", "Dramatic Tales"}},
|
||||||
|
{Model: gorm.Model{ID: 9}, Title: "Fantasy #1", AlternativeTitles: []string{"Fantasy World", "Magical Tales"}},
|
||||||
|
{Model: gorm.Model{ID: 10}, Title: "Thriller ~Uncut~"},
|
||||||
|
{Model: gorm.Model{ID: 11}, Title: "Epic ~ Saga ~"},
|
||||||
|
{Model: gorm.Model{ID: 12}, Title: "Journey - Dawn -", AlternativeTitles: []string{"Dawn Adventures", "Journey Chronicles"}},
|
||||||
|
{Model: gorm.Model{ID: 13}, Title: "Legends -Rise-", AlternativeTitles: []string{"Rise of Legends", "Legendary Tales"}},
|
||||||
|
{Model: gorm.Model{ID: 14}, Title: "Chronicles: Time", AlternativeTitles: []string{"Time Chronicles", "Chronicles of Ages"}},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add resources to index
|
||||||
|
for _, r := range resources {
|
||||||
|
err := AddResourceToIndex(r)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to add resource ID %d to index: %v", r.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
query string
|
||||||
|
expectedIDs []uint
|
||||||
|
unexpectedID uint
|
||||||
|
}{
|
||||||
|
// Basic searches
|
||||||
|
{query: "Adventure", expectedIDs: []uint{1, 6}},
|
||||||
|
{query: "Mystery", expectedIDs: []uint{2}},
|
||||||
|
{query: "Romance", expectedIDs: []uint{3}},
|
||||||
|
{query: "Sci-Fi", expectedIDs: []uint{4}},
|
||||||
|
{query: "Comedy", expectedIDs: []uint{5}},
|
||||||
|
// Exact matches
|
||||||
|
{query: "The Great Adventure", expectedIDs: []uint{1}},
|
||||||
|
{query: "Mystery of the Lost City", expectedIDs: []uint{2}},
|
||||||
|
{query: "Romance in Paris", expectedIDs: []uint{3}},
|
||||||
|
{query: "Sci-Fi Extravaganza", expectedIDs: []uint{4}},
|
||||||
|
{query: "Comedy Nights", expectedIDs: []uint{5}},
|
||||||
|
{query: "Action & Adventure", expectedIDs: []uint{6}},
|
||||||
|
{query: "Horror: The Awakening", expectedIDs: []uint{7}},
|
||||||
|
{query: "Drama @ Home", expectedIDs: []uint{8}},
|
||||||
|
{query: "Fantasy #1", expectedIDs: []uint{9}},
|
||||||
|
{query: "Thriller ~Uncut~", expectedIDs: []uint{10}},
|
||||||
|
{query: "Epic ~ Saga ~", expectedIDs: []uint{11}},
|
||||||
|
{query: "Journey - Dawn -", expectedIDs: []uint{12}},
|
||||||
|
{query: "Legends -Rise-", expectedIDs: []uint{13}},
|
||||||
|
{query: "Chronicles: Time", expectedIDs: []uint{14}},
|
||||||
|
// Searches with special characters
|
||||||
|
{query: "Action & Adventure", expectedIDs: []uint{6}},
|
||||||
|
{query: "Horror: The Awakening", expectedIDs: []uint{7}},
|
||||||
|
{query: "Drama @ Home", expectedIDs: []uint{8}},
|
||||||
|
{query: "Fantasy #1", expectedIDs: []uint{9}},
|
||||||
|
{query: "Thriller ~Uncut~", expectedIDs: []uint{10}},
|
||||||
|
{query: "Epic ~ Saga ~", expectedIDs: []uint{11}},
|
||||||
|
{query: "Journey - Dawn -", expectedIDs: []uint{12}},
|
||||||
|
{query: "Legends -Rise-", expectedIDs: []uint{13}},
|
||||||
|
{query: "Chronicles: Time", expectedIDs: []uint{14}},
|
||||||
|
// Case insensitivity
|
||||||
|
{query: "adventure", expectedIDs: []uint{1, 6}},
|
||||||
|
{query: "MYSTERY", expectedIDs: []uint{2}},
|
||||||
|
{query: "rOmAnCe", expectedIDs: []uint{3}},
|
||||||
|
// Searches using alternative titles
|
||||||
|
{query: "Adventure Time", expectedIDs: []uint{1, 6}},
|
||||||
|
{query: "Lost City Chronicles", expectedIDs: []uint{2}},
|
||||||
|
{query: "Love in Paris", expectedIDs: []uint{3}},
|
||||||
|
{query: "Future World", expectedIDs: []uint{4}},
|
||||||
|
{query: "Laugh Out Loud", expectedIDs: []uint{5}},
|
||||||
|
// Searches with special characters in alternative titles
|
||||||
|
{query: "Action-Packed", expectedIDs: []uint{6}},
|
||||||
|
{query: "Scary Movie", expectedIDs: []uint{7}},
|
||||||
|
{query: "Home Stories", expectedIDs: []uint{8}},
|
||||||
|
{query: "Fantasy World", expectedIDs: []uint{9}},
|
||||||
|
{query: "Epic Tales", expectedIDs: []uint{11}},
|
||||||
|
{query: "Dawn Adventures", expectedIDs: []uint{12}},
|
||||||
|
{query: "Rise of Legends", expectedIDs: []uint{13}},
|
||||||
|
{query: "Time Chronicles", expectedIDs: []uint{14}},
|
||||||
|
// Searches with special characters in queries
|
||||||
|
{query: "Horror:", expectedIDs: []uint{7}},
|
||||||
|
{query: "@ Home", expectedIDs: []uint{8}},
|
||||||
|
{query: "#1", expectedIDs: []uint{9}},
|
||||||
|
{query: "~Uncut~", expectedIDs: []uint{10}},
|
||||||
|
{query: "Uncut", expectedIDs: []uint{10}},
|
||||||
|
{query: "~ Saga ~", expectedIDs: []uint{11}},
|
||||||
|
{query: "Saga", expectedIDs: []uint{11}},
|
||||||
|
{query: "- Dawn -", expectedIDs: []uint{12}},
|
||||||
|
{query: "-Rise-", expectedIDs: []uint{13}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.query, func(t *testing.T) {
|
||||||
|
resultIDs, err := SearchResource(test.query)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Search failed for query '%s': %v", test.query, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for expected IDs
|
||||||
|
for _, expectedID := range test.expectedIDs {
|
||||||
|
found := false
|
||||||
|
for _, resultID := range resultIDs {
|
||||||
|
if resultID == expectedID {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("Expected ID %d not found in results for query '%s'", expectedID, test.query)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for unexpected ID
|
||||||
|
if test.unexpectedID != 0 {
|
||||||
|
for _, resultID := range resultIDs {
|
||||||
|
if resultID == test.unexpectedID {
|
||||||
|
t.Errorf("Unexpected ID %d found in results for query '%s'", test.unexpectedID, test.query)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsStopWord(t *testing.T) {
|
||||||
|
Init()
|
||||||
|
defer TearDown()
|
||||||
|
|
||||||
|
stopWords := []string{"the", "is", "at", "which", "on", "and", "a", "an", "in", "to", "of"}
|
||||||
|
nonStopWords := []string{"adventure", "mystery", "romance", "sci-fi", "comedy", "action", "horror"}
|
||||||
|
|
||||||
|
for _, word := range stopWords {
|
||||||
|
if !IsStopWord(word) {
|
||||||
|
t.Errorf("Expected '%s' to be identified as a stop word", word)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, word := range nonStopWords {
|
||||||
|
if IsStopWord(word) {
|
||||||
|
t.Errorf("Expected '%s' to not be identified as a stop word", word)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -291,34 +291,57 @@ func SearchResource(query string, page int) ([]model.ResourceView, int, error) {
|
|||||||
// split query to search
|
// split query to search
|
||||||
keywords := splitQuery(query)
|
keywords := splitQuery(query)
|
||||||
var temp []uint
|
var temp []uint
|
||||||
first := true
|
haveTag := false
|
||||||
for _, keyword := range keywords {
|
for _, keyword := range keywords {
|
||||||
if keyword == "" {
|
if len([]rune(keyword)) <= maxTagLength {
|
||||||
continue
|
exists, err := dao.ExistsTag(keyword)
|
||||||
}
|
if err != nil {
|
||||||
if utils.OnlyPunctuation(keyword) {
|
return nil, 0, err
|
||||||
continue
|
}
|
||||||
|
if exists {
|
||||||
|
haveTag = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if haveTag {
|
||||||
|
first := true
|
||||||
|
for _, keyword := range keywords {
|
||||||
|
if keyword == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if utils.OnlyPunctuation(keyword) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
res, err := searchWithKeyword(keyword)
|
res, err := searchWithKeyword(keyword)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
if len(res) == 0 && search.IsStopWord(keyword) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if first {
|
||||||
|
temp = utils.RemoveDuplicate(res)
|
||||||
|
first = false
|
||||||
|
} else {
|
||||||
|
temp1 := make([]uint, 0)
|
||||||
|
for _, id := range temp {
|
||||||
|
for _, id2 := range res {
|
||||||
|
if id == id2 {
|
||||||
|
temp1 = append(temp1, id)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temp = temp1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res, err := searchWithKeyword(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
if first {
|
temp = res
|
||||||
temp = utils.RemoveDuplicate(res)
|
|
||||||
first = false
|
|
||||||
} else {
|
|
||||||
temp1 := make([]uint, 0)
|
|
||||||
for _, id := range temp {
|
|
||||||
for _, id2 := range res {
|
|
||||||
if id == id2 {
|
|
||||||
temp1 = append(temp1, id)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
temp = temp1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
resources = append(resources, temp...)
|
resources = append(resources, temp...)
|
||||||
resources = utils.RemoveDuplicate(resources)
|
resources = utils.RemoveDuplicate(resources)
|
||||||
|
Reference in New Issue
Block a user