Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*
!Gopkg.*
!*.go
!server/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.db
gggtracker
/vendor
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM golang:alpine
FROM golang:1.10-alpine

WORKDIR /go/src/github.com/ccbrown/gggtracker
ADD . .

RUN apk add --no-cache git && go get -t ./...
RUN apk add --no-cache git
RUN wget -O - https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

ADD . .
RUN dep ensure
RUN go vet . && go test -v ./...
RUN go build .

Expand Down
224 changes: 224 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/PuerkitoBio/goquery"
version = "1.3.0"

[[constraint]]
name = "github.com/boltdb/bolt"
version = "1.3.1"

[[constraint]]
name = "github.com/labstack/echo"
version = "3.2.6"

[[constraint]]
name = "github.com/sirupsen/logrus"
version = "1.0.4"

[[constraint]]
name = "github.com/spf13/pflag"
version = "1.0.0"

[[constraint]]
name = "github.com/spf13/viper"
version = "1.0.0"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"

[prune]
go-tests = true
unused-packages = true
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"net/http"
"path"

log "github.com/Sirupsen/logrus"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"

Expand Down
42 changes: 42 additions & 0 deletions server/activity.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,52 @@
package server

import (
"net/http"
"strings"
"time"
)

type Activity interface {
ActivityTime() time.Time
ActivityKey() uint32
}

func ActivityFilterForRequest(r *http.Request) func(Activity) bool {
subdomain := ""
if r.Host != "" {
subdomain = strings.Split(r.Host, ".")[0]
}

includeReddit := false
includeForumHost := map[string]bool{}

switch subdomain {
case "br":
includeForumHost["br.pathofexile.com"] = true
case "ru":
includeForumHost["ru.pathofexile.com"] = true
case "th":
includeForumHost["th.pathofexile.com"] = true
case "de":
includeForumHost["de.pathofexile.com"] = true
case "fr":
includeForumHost["fr.pathofexile.com"] = true
case "es":
includeForumHost["es.pathofexile.com"] = true
default:
includeReddit = true
includeForumHost["www.pathofexile.com"] = true
}

return func(a Activity) bool {
switch a := a.(type) {
case *ForumPost:
return includeForumHost[a.Host]
case *RedditComment:
return includeReddit
case *RedditPost:
return includeReddit
}
return false
}
}
2 changes: 1 addition & 1 deletion server/activity_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type jsonResponse struct {

func ActivityHandler(db *Database) echo.HandlerFunc {
return func(c echo.Context) error {
activity, next := db.Activity(c.QueryParam("next"), 50)
activity, next := db.Activity(c.QueryParam("next"), 50, ActivityFilterForRequest(c.Request()))
response := jsonResponse{
Next: next,
}
Expand Down
Loading