✨ Better down vote author filter system
This commit is contained in:
parent
a4d8a3b37f
commit
ee62f3bef8
6
go.mod
6
go.mod
@ -4,11 +4,8 @@ go 1.21.6
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024524-cfb73fde1951
|
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024524-cfb73fde1951
|
||||||
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745
|
|
||||||
github.com/go-playground/validator/v10 v10.17.0
|
github.com/go-playground/validator/v10 v10.17.0
|
||||||
github.com/gofiber/fiber/v2 v2.52.4
|
github.com/gofiber/fiber/v2 v2.52.4
|
||||||
github.com/gofiber/template/html/v2 v2.1.1
|
|
||||||
github.com/google/uuid v1.6.0
|
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/pemistahl/lingua-go v1.4.0
|
github.com/pemistahl/lingua-go v1.4.0
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
@ -31,8 +28,7 @@ require (
|
|||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||||
github.com/gofiber/template v1.8.3 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/gofiber/utils v1.1.0 // indirect
|
|
||||||
github.com/hashicorp/consul/api v1.29.1 // indirect
|
github.com/hashicorp/consul/api v1.29.1 // indirect
|
||||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
|
10
go.sum
10
go.sum
@ -1,9 +1,5 @@
|
|||||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024414-abba3b1c259d h1:cBDO9mJRz6BW3OXm14svCb+LtERp332nOmrfs6AKNQg=
|
|
||||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024414-abba3b1c259d/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
|
|
||||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024524-cfb73fde1951 h1:RgZJK4PXhrjhUX75BclBCg2xfetMkswcMwMqfTBtryQ=
|
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024524-cfb73fde1951 h1:RgZJK4PXhrjhUX75BclBCg2xfetMkswcMwMqfTBtryQ=
|
||||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024524-cfb73fde1951/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
|
git.solsynth.dev/hydrogen/dealer v0.0.0-20240716024524-cfb73fde1951/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
|
||||||
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 h1:40BUsQMNXjqHyytkyF9py1HjTAWlRgO6R57YXUrHNy4=
|
|
||||||
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745/go.mod h1:FsQGSLTl0gvo+9Jmbot02S72suyF9tFTrzDj70Xhifo=
|
|
||||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
@ -61,12 +57,6 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
|
|||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/gofiber/fiber/v2 v2.52.4 h1:P+T+4iK7VaqUsq2PALYEfBBo6bJZ4q3FP8cZ84EggTM=
|
github.com/gofiber/fiber/v2 v2.52.4 h1:P+T+4iK7VaqUsq2PALYEfBBo6bJZ4q3FP8cZ84EggTM=
|
||||||
github.com/gofiber/fiber/v2 v2.52.4/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
|
github.com/gofiber/fiber/v2 v2.52.4/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
|
||||||
github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc=
|
|
||||||
github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8=
|
|
||||||
github.com/gofiber/template/html/v2 v2.1.1 h1:QEy3O3EBkvwDthy5bXVGUseOyO6ldJoiDxlF4+MJiV8=
|
|
||||||
github.com/gofiber/template/html/v2 v2.1.1/go.mod h1:2G0GHHOUx70C1LDncoBpe4T6maQbNa4x1CVNFW0wju0=
|
|
||||||
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
|
|
||||||
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
|
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
|
||||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
|
@ -12,10 +12,12 @@ func listRecommendationDefault(c *fiber.Ctx) error {
|
|||||||
take := c.QueryInt("take", 0)
|
take := c.QueryInt("take", 0)
|
||||||
offset := c.QueryInt("offset", 0)
|
offset := c.QueryInt("offset", 0)
|
||||||
realmId := c.QueryInt("realmId", 0)
|
realmId := c.QueryInt("realmId", 0)
|
||||||
maxDownVote := c.QueryInt("maxDownVote", 3)
|
maxDownVote := c.QueryInt("maxDownVote", 15)
|
||||||
|
|
||||||
tx := database.C.Joins("Author").Where("\"Author\".total_downvote <= ?", maxDownVote)
|
tx := services.FilterPostDraft(database.C)
|
||||||
tx = services.FilterPostDraft(tx)
|
if maxDownVote > 0 {
|
||||||
|
tx = tx.Joins("Author").Where("\"Author\".total_downvote - \"Author\".total_upvote <= ?", maxDownVote)
|
||||||
|
}
|
||||||
if realmId > 0 {
|
if realmId > 0 {
|
||||||
if realm, err := services.GetRealmWithExtID(uint(realmId)); err != nil {
|
if realm, err := services.GetRealmWithExtID(uint(realmId)); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("realm was not found: %v", err))
|
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("realm was not found: %v", err))
|
||||||
@ -45,9 +47,12 @@ func listRecommendationShuffle(c *fiber.Ctx) error {
|
|||||||
take := c.QueryInt("take", 0)
|
take := c.QueryInt("take", 0)
|
||||||
offset := c.QueryInt("offset", 0)
|
offset := c.QueryInt("offset", 0)
|
||||||
realmId := c.QueryInt("realmId", 0)
|
realmId := c.QueryInt("realmId", 0)
|
||||||
maxDownVote := c.QueryInt("maxDownVote", 3)
|
maxDownVote := c.QueryInt("maxDownVote", 15)
|
||||||
|
|
||||||
tx := database.C.Joins("Author").Where("\"Author\".total_downvote <= ?", maxDownVote)
|
tx := services.FilterPostDraft(database.C)
|
||||||
|
if maxDownVote > 0 {
|
||||||
|
tx = tx.Joins("Author").Where("\"Author\".total_downvote - \"Author\".total_upvote <= ?", maxDownVote)
|
||||||
|
}
|
||||||
tx = services.FilterPostDraft(tx)
|
tx = services.FilterPostDraft(tx)
|
||||||
if realmId > 0 {
|
if realmId > 0 {
|
||||||
if realm, err := services.GetRealmWithExtID(uint(realmId)); err != nil {
|
if realm, err := services.GetRealmWithExtID(uint(realmId)); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user