Skip to content

Commit

Permalink
Merge pull request #53 from fjnkt98/develop
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
fjnkt98 committed Oct 22, 2023
2 parents 5465b99 + 9c1958e commit f374e15
Show file tree
Hide file tree
Showing 34 changed files with 1,342 additions and 406 deletions.
2 changes: 1 addition & 1 deletion backend/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.6
0.1.7
5 changes: 5 additions & 0 deletions backend/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ var serverCmd = &cobra.Command{

// API handler registration
e.GET("/api/search/problem", problemSearcher.HandleGET)
e.POST("/api/search/problem", problemSearcher.HandlePOST)
e.GET("/api/search/user", userSearcher.HandleGET)
e.POST("/api/search/user", userSearcher.HandlePOST)
e.GET("/api/search/submission", submissionSearcher.HandleGET)
e.POST("/api/search/submission", submissionSearcher.HandlePOST)
e.GET("/api/recommend/problem", recommendSearcher.HandleGET)
e.POST("/api/recommend/problem", recommendSearcher.HandlePOST)
e.GET("/api/list/category", listSearcher.HandleCategory)
e.GET("/api/list/language", listSearcher.HandleLanguage)
e.GET("/api/list/language/group", listSearcher.HandleLanguageGroup)
e.GET("/api/list/contest", listSearcher.HandleContest)
e.GET("/api/list/problem", listSearcher.HandleProblem)

Expand Down
8 changes: 4 additions & 4 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/tdewolff/minify v2.3.6+incompatible
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
golang.org/x/sync v0.3.0
golang.org/x/text v0.12.0
golang.org/x/text v0.13.0
)

require (
Expand All @@ -41,9 +41,9 @@ require (
github.com/tdewolff/test v1.0.9 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.23.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
Expand Down
8 changes: 8 additions & 0 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,16 @@ github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -120,9 +124,13 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
35 changes: 35 additions & 0 deletions backend/list/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,41 @@ func (s *Searcher) HandleLanguage(c echo.Context) error {
}
}

func (s *Searcher) HandleLanguageGroup(c echo.Context) error {
if languages, ok := s.c.Get("language_groups"); ok {
return c.JSON(http.StatusOK, languages)
} else {
rows, err := s.db.Query(
`
SELECT
DISTINCT "group"
FROM
"languages"
ORDER BY
"group"
`,
)
if err != nil {
slog.Error("failed to get a list of language group", slog.String("error", err.Error()))
return c.String(http.StatusInternalServerError, "failed to get language group list")
}
defer rows.Close()

groups := make([]string, 0, 12)
for rows.Next() {
var group string
if err := rows.Scan(&group); err != nil {
slog.Error("failed to scan row for fetching a list of language group", slog.String("error", err.Error()))
return c.String(http.StatusInternalServerError, "failed to scan language group")
}
groups = append(groups, group)
}
s.c.Set("language_groups", groups, cache.DefaultExpiration)

return c.JSON(http.StatusOK, groups)
}
}

func (s *Searcher) HandleContest(c echo.Context) error {
category := c.QueryParam("category")

Expand Down
Loading

0 comments on commit f374e15

Please sign in to comment.