Open platform to collect and prioritize feedback
[WIP] Duplicate Status (#239)
Guilherme Oenningf7d4baed2e74
diff --git a/app/actions/idea.go b/app/actions/idea.goindex 999cf9ec6..e0f3276a3 100644--- a/app/actions/idea.go+++ b/app/actions/idea.go@@ -120,7 +120,8 @@ func (input *AddNewComment) Validate(services *app.Services) *validate.Result {// SetResponse represents the action to update an idea responsetype SetResponse struct {- Model *models.SetResponse+ Model *models.SetResponse+ Original *models.Idea}// Initialize the model@@ -138,11 +139,27 @@ func (input *SetResponse) IsAuthorized(user *models.User) bool {func (input *SetResponse) Validate(services *app.Services) *validate.Result {result := validate.Success()- if input.Model.Status < models.IdeaOpen || input.Model.Status > models.IdeaPlanned {+ if input.Model.Status < models.IdeaOpen || input.Model.Status > models.IdeaDuplicate {result.AddFieldFailure("status", "Status is invalid.")}- if input.Model.Status != models.IdeaOpen && input.Model.Text == "" {+ if input.Model.Status == models.IdeaDuplicate {+ if input.Model.OriginalNumber == input.Model.Number {+ result.AddFieldFailure("originalNumber", "Cannot be a duplicate of itself")+ }++ original, err := services.Ideas.GetByNumber(input.Model.OriginalNumber)+ if err != nil {+ if err == app.ErrNotFound {+ result.AddFieldFailure("originalNumber", "Original idea not found")+ } else {+ return validate.Error(err)+ }+ }+ if original != nil {+ input.Original = original+ }+ } else if input.Model.Status != models.IdeaOpen && input.Model.Text == "" {result.AddFieldFailure("text", "Description is required.")}diff --git a/app/handlers/idea.go b/app/handlers/idea.goindex c4d877c15..02c93fc96 100644--- a/app/handlers/idea.go+++ b/app/handlers/idea.go@@ -3,6 +3,7 @@ package handlersimport ("github.com/getfider/fider/app""github.com/getfider/fider/app/actions"+ "github.com/getfider/fider/app/models""github.com/getfider/fider/app/pkg/web")@@ -26,6 +27,17 @@ func Index() web.HandlerFunc {}}+// GetIdeas return basic model of all tenant ideas+func GetIdeas() web.HandlerFunc {+ return func(c web.Context) error {+ ideas, err := c.Services().Ideas.GetAllBasic()+ if err != nil {+ return c.Failure(err)+ }+ return c.Ok(ideas)+ }+}+// PostIdea creates a new idea on current tenantfunc PostIdea() web.HandlerFunc {return func(c web.Context) error {@@ -122,7 +134,12 @@ func SetResponse() web.HandlerFunc {return c.HandleValidation(result)}- err := c.Services().Ideas.SetResponse(input.Model.Number, input.Model.Text, c.User().ID, input.Model.Status)+ var err error+ if input.Model.Status == models.IdeaDuplicate {+ err = c.Services().Ideas.MarkAsDuplicate(input.Model.Number, input.Original.Number, c.User().ID)+ } else {+ err = c.Services().Ideas.SetResponse(input.Model.Number, input.Model.Text, c.User().ID, input.Model.Status)+ }if err != nil {return c.Failure(err)}diff --git a/app/handlers/idea_test.go b/app/handlers/idea_test.goindex 44d43fd2c..d12fadc17 100644--- a/app/handlers/idea_test.go+++ b/app/handlers/idea_test.go@@ -18,7 +18,23 @@ func TestIndexHandler(t *testing.T) {server, _ := mock.NewServer()code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).Execute(handlers.Index())- Expect(code).To(Equal(200))+ Expect(code).To(Equal(http.StatusOK))+}++func TestGetIdeasHandler(t *testing.T) {+ RegisterTestingT(t)++ server, services := mock.NewServer()+ services.Ideas.Add("My Idea", "My Idea Description", mock.JonSnow.ID)+ services.Ideas.Add("My Idea 2", "My Idea 2 Description", mock.JonSnow.ID)++ code, query := server.OnTenant(mock.DemoTenant).+ AsUser(mock.JonSnow).+ ExecuteAsJSON(handlers.GetIdeas())++ Expect(code).To(Equal(http.StatusOK))+ Expect(query.IsArray()).To(BeTrue())+ Expect(query.ArrayLength()).To(Equal(2))}func TestDetailsHandler(t *testing.T) {@@ -280,3 +296,57 @@ func TestSetResponseHandler_Unauthorized(t *testing.T) {Expect(code).To(Equal(http.StatusForbidden))Expect(idea.Status).To(Equal(models.IdeaOpen))}++func TestSetResponseHandler_Duplicate(t *testing.T) {+ RegisterTestingT(t)++ server, services := mock.NewServer()+ idea1, _ := services.Ideas.Add("The Idea #1", "The Description #1", mock.AryaStark.ID)+ idea2, _ := services.Ideas.Add("The Idea #2", "The Description #2", mock.AryaStark.ID)++ body := fmt.Sprintf(`{ "status": %d, "originalNumber": %d }`, models.IdeaDuplicate, idea2.Number)+ code, _ := server.+ OnTenant(mock.DemoTenant).+ AsUser(mock.JonSnow).+ AddParam("number", idea1.ID).+ ExecutePost(handlers.SetResponse(), body)+ Expect(code).To(Equal(http.StatusOK))++ idea1, _ = services.Ideas.GetByNumber(idea1.Number)+ Expect(idea1.Status).To(Equal(models.IdeaDuplicate))++ idea2, _ = services.Ideas.GetByNumber(idea2.Number)+ Expect(idea2.Status).To(Equal(models.IdeaOpen))+}++func TestSetResponseHandler_Duplicate_NotFound(t *testing.T) {+ RegisterTestingT(t)++ server, services := mock.NewServer()+ idea1, _ := services.Ideas.Add("The Idea #1", "The Description #1", mock.AryaStark.ID)++ body := fmt.Sprintf(`{ "status": %d, "originalNumber": 9999 }`, models.IdeaDuplicate)+ code, _ := server.+ OnTenant(mock.DemoTenant).+ AsUser(mock.JonSnow).+ AddParam("number", idea1.ID).+ ExecutePost(handlers.SetResponse(), body)++ Expect(code).To(Equal(http.StatusBadRequest))+}++func TestSetResponseHandler_Duplicate_Itself(t *testing.T) {+ RegisterTestingT(t)++ server, services := mock.NewServer()+ idea, _ := services.Ideas.Add("The Idea #1", "The Description #1", mock.AryaStark.ID)++ body := fmt.Sprintf(`{ "status": %d, "originalNumber": %d }`, models.IdeaDuplicate, idea.Number)+ code, _ := server.+ OnTenant(mock.DemoTenant).+ AsUser(mock.JonSnow).+ AddParam("number", idea.ID).+ ExecutePost(handlers.SetResponse(), body)++ Expect(code).To(Equal(http.StatusBadRequest))+}diff --git a/app/models/feedback.go b/app/models/feedback.goindex 8f2fcd447..57724394c 100644--- a/app/models/feedback.go+++ b/app/models/feedback.go@@ -24,7 +24,17 @@ type Idea struct {// CanBeSupported returns true if this idea can be Supported/UnSupportedfunc (i *Idea) CanBeSupported() bool {- return i.Status != IdeaCompleted && i.Status != IdeaDeclined+ return i.Status != IdeaCompleted && i.Status != IdeaDeclined && i.Status != IdeaDuplicate+}++//BasicIdea is a subset of Idea with few fields+type BasicIdea struct {+ ID int `json:"id"`+ Number int `json:"number"`+ Title string `json:"title"`+ Slug string `json:"slug"`+ TotalSupporters int `json:"totalSupporters"`+ Status int `json:"status"`}// NewIdea represents a new idea@@ -48,16 +58,26 @@ type NewComment struct {// SetResponse represents the action to update an idea responsetype SetResponse struct {- Number int `route:"number"`- Status int `json:"status"`- Text string `json:"text"`+ Number int `route:"number"`+ Status int `json:"status"`+ Text string `json:"text"`+ OriginalNumber int `json:"originalNumber"`}//IdeaResponse is a staff response to a given ideatype IdeaResponse struct {- Text string `json:"text"`- RespondedOn time.Time `json:"respondedOn"`- User *User `json:"user"`+ Text string `json:"text"`+ RespondedOn time.Time `json:"respondedOn"`+ User *User `json:"user"`+ Original *OriginalIdea `json:"original"`+}++//OriginalIdea holds details of the original idea of a duplicate+type OriginalIdea struct {+ Number int `json:"number"`+ Title string `json:"title"`+ Slug string `json:"slug"`+ Status int `json:"status"`}//Comment represents an user comment on an idea@@ -107,4 +127,6 @@ var (IdeaDeclined = 3//IdeaPlanned is used when organizers have accepted an idea and it's on the roadmapIdeaPlanned = 4+ //IdeaDuplicate is used when the idea has already been posted before+ IdeaDuplicate = 5)diff --git a/app/pkg/jsonq/jsonq.go b/app/pkg/jsonq/jsonq.goindex 4f0e8f4f5..799a27300 100644--- a/app/pkg/jsonq/jsonq.go+++ b/app/pkg/jsonq/jsonq.go@@ -7,17 +7,23 @@ import (//Query is a JSON query interfacetype Query struct {- m map[string]*json.RawMessage+ json string+ m map[string]*json.RawMessage}//New creates a new Query object based on given input as a JSONfunc New(content string) *Query {var m map[string]*json.RawMessage- err := json.Unmarshal([]byte(content), &m)- if err != nil {- panic(err)+ if len(content) > 0 && string(content[0]) == "{" {+ err := json.Unmarshal([]byte(content), &m)+ if err != nil {+ panic(err)+ }+ }+ return &Query{+ m: m,+ json: content,}- return &Query{m: m}}//String returns a string value from the json object based on its key@@ -31,6 +37,21 @@ func (q *Query) String(key string) (string, error) {return "", nil}+//IsArray returns true if the json object is an array+func (q *Query) IsArray() bool {+ return q.m == nil+}++//ArrayLength returns number of elements in the array+func (q *Query) ArrayLength() int {+ if q.IsArray() {+ var arr []interface{}+ json.Unmarshal([]byte(q.json), &arr)+ return len(arr)+ }+ return 0+}+//Contains returns true if the json object has the keyfunc (q *Query) Contains(key string) bool {return q.get(key) != nildiff --git a/app/pkg/jsonq/jsonq_test.go b/app/pkg/jsonq/jsonq_test.goindex 5ba2dafc9..dbc1f0dbe 100644--- a/app/pkg/jsonq/jsonq_test.go+++ b/app/pkg/jsonq/jsonq_test.go@@ -25,15 +25,26 @@ func TestContains(t *testing.T) {RegisterTestingT(t)query := jsonq.New(`{ "name": "Jon Snow" }`)+ Expect(query.IsArray()).To(BeFalse())Expect(query.Contains("name")).To(BeTrue())Expect(query.Contains("what")).To(BeFalse())Expect(query.Contains("feature.name")).To(BeFalse())}+func TestIsArray(t *testing.T) {+ RegisterTestingT(t)++ query := jsonq.New(`[0,1,2,3]`)+ Expect(query.IsArray()).To(BeTrue())+ Expect(query.ArrayLength()).To(Equal(4))+}+func TestContainsNested(t *testing.T) {RegisterTestingT(t)query := jsonq.New(`{ "failures": { "name": "Name is required" } }`)+ Expect(query.IsArray()).To(BeFalse())+Expect(query.Contains("failures")).To(BeTrue())Expect(query.Contains("failures.name")).To(BeTrue())diff --git a/app/storage/inmemory/idea.go b/app/storage/inmemory/idea.goindex 008a10425..218f8bf83 100644--- a/app/storage/inmemory/idea.go+++ b/app/storage/inmemory/idea.go@@ -82,6 +82,22 @@ func (s *IdeaStorage) GetAll() ([]*models.Idea, error) {return s.ideas, nil}+// GetAllBasic returns all tenant ideas in a Basic model+func (s *IdeaStorage) GetAllBasic() ([]*models.BasicIdea, error) {+ var result = make([]*models.BasicIdea, len(s.ideas))+ for i, idea := range s.ideas {+ result[i] = &models.BasicIdea{+ ID: idea.ID,+ Number: idea.Number,+ Title: idea.Title,+ Slug: idea.Slug,+ TotalSupporters: idea.TotalSupporters,+ Status: idea.Status,+ }+ }+ return result, nil+}+// GetCommentsByIdea returns all coments from given ideafunc (s *IdeaStorage) GetCommentsByIdea(number int) ([]*models.Comment, error) {return make([]*models.Comment, 0), nil@@ -153,6 +169,32 @@ func (s *IdeaStorage) SetResponse(number int, text string, userID, status int) ereturn nil}+// MarkAsDuplicate set idea as a duplicate of another idea+func (s *IdeaStorage) MarkAsDuplicate(number, originalNumber, userID int) error {+ idea, err := s.GetByNumber(number)+ if err != nil {+ return err+ }+ original, err := s.GetByNumber(originalNumber)+ if err != nil {+ return err+ }++ idea.Status = models.IdeaDuplicate+ idea.Response = &models.IdeaResponse{+ Original: &models.OriginalIdea{+ Number: original.Number,+ Title: original.Title,+ Slug: original.Slug,+ Status: original.Status,+ },+ Text: "",+ User: &models.User{ID: userID},+ RespondedOn: time.Now(),+ }+ return nil+}+// SupportedBy returns a list of Idea ID supported by given userfunc (s *IdeaStorage) SupportedBy(userID int) ([]int, error) {return s.ideasSupportedBy[userID], nildiff --git a/app/storage/postgres/idea.go b/app/storage/postgres/idea.goindex 4d7396e53..8f190a07f 100644--- a/app/storage/postgres/idea.go+++ b/app/storage/postgres/idea.go@@ -1,6 +1,7 @@package postgresimport (+ "errors""fmt""math""time"@@ -29,6 +30,10 @@ type dbIdea struct {Response sql.NullString `db:"response"`RespondedOn dbx.NullTime `db:"response_date"`ResponseUser *dbUser `db:"response_user"`+ OriginalNumber sql.NullInt64 `db:"original_number"`+ OriginalTitle sql.NullString `db:"original_title"`+ OriginalSlug sql.NullString `db:"original_slug"`+ OriginalStatus sql.NullInt64 `db:"original_status"`Tags []int64 `db:"tags"`}@@ -60,10 +65,29 @@ func (i *dbIdea) toModel() *models.Idea {RespondedOn: i.RespondedOn.Time,User: i.ResponseUser.toModel(),}+ if idea.Status == models.IdeaDuplicate && i.OriginalNumber.Valid {+ idea.Response.Original = &models.OriginalIdea{+ Number: int(i.OriginalNumber.Int64),+ Slug: i.OriginalSlug.String,+ Title: i.OriginalTitle.String,+ Status: int(i.OriginalStatus.Int64),+ }+ }}return idea}+func (i *dbIdea) toBasic() *models.BasicIdea {+ return &models.BasicIdea{+ ID: i.ID,+ Number: i.Number,+ Title: i.Title,+ Slug: i.Slug,+ TotalSupporters: i.TotalSupporters,+ Status: i.Status,+ }+}+type dbComment struct {ID int `db:"id"`Content string `db:"content"`@@ -126,6 +150,10 @@ var (r.name AS response_user_name,r.email AS response_user_email,r.role AS response_user_role,+ d.number AS original_number,+ d.title AS original_title,+ d.slug AS original_slug,+ d.status AS original_status,array_remove(array_agg(t.id), NULL) AS tags,COALESCE(%s, false) AS viewer_supportedFROM ideas i@@ -135,11 +163,13 @@ var (ON r.id = i.response_user_idLEFT JOIN idea_tags itON it.idea_id = i.id+ LEFT JOIN ideas d+ ON d.id = i.original_idLEFT JOIN tags tON t.id = it.tag_id%sWHERE %s- GROUP BY i.id, u.id, r.id`+ GROUP BY i.id, u.id, r.id, d.id`)func (s *IdeaStorage) getIdeaQuery(filter string) string {@@ -182,7 +212,7 @@ func (s *IdeaStorage) GetByNumber(number int) (*models.Idea, error) {// GetAll returns all tenant ideasfunc (s *IdeaStorage) GetAll() ([]*models.Idea, error) {var ideas []*dbIdea- err := s.trx.Select(&ideas, s.getIdeaQuery("i.tenant_id = $1"), s.tenant.ID)+ err := s.trx.Select(&ideas, s.getIdeaQuery("i.tenant_id = $1 AND i.status != $2"), s.tenant.ID, models.IdeaDuplicate)if err != nil {return nil, err}@@ -194,6 +224,23 @@ func (s *IdeaStorage) GetAll() ([]*models.Idea, error) {return result, nil}+// GetAllBasic returns all tenant ideas in a Basic model+func (s *IdeaStorage) GetAllBasic() ([]*models.BasicIdea, error) {+ var ideas []*dbIdea+ innerQuery := s.getIdeaQuery("i.tenant_id = $1 AND i.status != $2")+ query := fmt.Sprintf("SELECT id, number, title, slug, supporters, status FROM (%s) AS q", innerQuery)+ err := s.trx.Select(&ideas, query, s.tenant.ID, models.IdeaDuplicate)+ if err != nil {+ return nil, err+ }++ var result = make([]*models.BasicIdea, len(ideas))+ for i, idea := range ideas {+ result[i] = idea.toBasic()+ }+ return result, nil+}+// GetCommentsByIdea returns all coments from given ideafunc (s *IdeaStorage) GetCommentsByIdea(number int) ([]*models.Comment, error) {comments := []*dbComment{}@@ -319,6 +366,10 @@ func (s *IdeaStorage) RemoveSupporter(number, userID int) error {// SetResponse changes current idea responsefunc (s *IdeaStorage) SetResponse(number int, text string, userID, status int) error {+ if status == models.IdeaDuplicate {+ return errors.New("Use MarkAsDuplicate to change an idea status to Duplicate")+ }+idea, err := s.GetByNumber(number)if err != nil {return err@@ -328,14 +379,47 @@ func (s *IdeaStorage) SetResponse(number int, text string, userID, status int) eif idea.Status == status && idea.Response != nil {respondedOn = idea.Response.RespondedOn}-return s.trx.Execute(`UPDATE ideas- SET response = $3, response_date = $4, response_user_id = $5, status = $6+ SET response = $3, original_id = NULL, response_date = $4, response_user_id = $5, status = $6WHERE id = $1 and tenant_id = $2`, idea.ID, s.tenant.ID, text, respondedOn, userID, status)}+// MarkAsDuplicate set idea as a duplicate of another idea+func (s *IdeaStorage) MarkAsDuplicate(number, originalNumber, userID int) error {+ idea, err := s.GetByNumber(number)+ if err != nil {+ return err+ }+ original, err := s.GetByNumber(originalNumber)+ if err != nil {+ return err+ }++ respondedOn := time.Now()+ if idea.Status == models.IdeaDuplicate && idea.Response != nil {+ respondedOn = idea.Response.RespondedOn+ }++ users, err := s.trx.QueryIntArray("SELECT user_id FROM idea_supporters WHERE idea_id = $1", idea.ID)+ if err != nil {+ return err+ }++ for _, u := range users {+ if err := s.AddSupporter(original.Number, u); err != nil {+ return err+ }+ }++ return s.trx.Execute(`+ UPDATE ideas+ SET response = '', original_id = $3, response_date = $4, response_user_id = $5, status = $6+ WHERE id = $1 and tenant_id = $2+ `, idea.ID, s.tenant.ID, original.ID, respondedOn, userID, models.IdeaDuplicate)+}+// SupportedBy returns a list of Idea ID supported by given userfunc (s *IdeaStorage) SupportedBy(userID int) ([]int, error) {return s.trx.QueryIntArray("SELECT idea_id FROM idea_supporters WHERE user_id = $1", userID)diff --git a/app/storage/postgres/idea_test.go b/app/storage/postgres/idea_test.goindex 04d4408dc..160ed950d 100644--- a/app/storage/postgres/idea_test.go+++ b/app/storage/postgres/idea_test.go@@ -39,6 +39,22 @@ func TestIdeaStorage_GetAll(t *testing.T) {Expect(dbIdeas[1].User.Name).To(Equal("Arya Stark"))Expect(dbIdeas[1].TotalSupporters).To(Equal(5))Expect(dbIdeas[1].Status).To(Equal(models.IdeaCompleted))++ dbBasicIdeas, err := ideas.GetAllBasic()+ Expect(err).To(BeNil())+ Expect(dbBasicIdeas).To(HaveLen(2))++ Expect(dbBasicIdeas[0].Title).To(Equal("Idea #1"))+ Expect(dbBasicIdeas[0].Slug).To(Equal("idea-1"))+ Expect(dbBasicIdeas[0].Number).To(Equal(1))+ Expect(dbBasicIdeas[0].TotalSupporters).To(Equal(0))+ Expect(dbBasicIdeas[0].Status).To(Equal(models.IdeaStarted))++ Expect(dbBasicIdeas[1].Title).To(Equal("Idea #2"))+ Expect(dbBasicIdeas[1].Slug).To(Equal("idea-2"))+ Expect(dbBasicIdeas[1].Number).To(Equal(2))+ Expect(dbBasicIdeas[1].TotalSupporters).To(Equal(5))+ Expect(dbBasicIdeas[1].Status).To(Equal(models.IdeaCompleted))}func TestIdeaStorage_AddAndGet(t *testing.T) {@@ -283,6 +299,35 @@ func TestIdeaStorage_SetResponse_ChangeText(t *testing.T) {Expect(idea.Response.RespondedOn).Should(BeTemporally(">", respondedOn))}+func TestIdeaStorage_SetResponse_AsDuplicate(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ ideas.SetCurrentTenant(demoTenant)+ idea1, _ := ideas.Add("My new idea", "with this description", 1)+ ideas.AddSupporter(idea1.Number, 1)+ idea2, _ := ideas.Add("My other idea", "with similar description", 2)+ ideas.AddSupporter(idea2.Number, 2)++ ideas.MarkAsDuplicate(idea2.Number, idea1.Number, 1)+ idea1, _ = ideas.GetByID(idea1.ID)++ Expect(idea1.TotalSupporters).To(Equal(2))+ Expect(idea1.Status).To(Equal(models.IdeaOpen))+ Expect(idea1.Response).To(BeNil())++ idea2, _ = ideas.GetByID(idea2.ID)++ Expect(idea2.Response.Text).To(Equal(""))+ Expect(idea2.TotalSupporters).To(Equal(1))+ Expect(idea2.Status).To(Equal(models.IdeaDuplicate))+ Expect(idea2.Response.User.ID).To(Equal(1))+ Expect(idea2.Response.Original.Number).To(Equal(idea1.Number))+ Expect(idea2.Response.Original.Title).To(Equal(idea1.Title))+ Expect(idea2.Response.Original.Slug).To(Equal(idea1.Slug))+ Expect(idea2.Response.Original.Status).To(Equal(idea1.Status))+}+func TestIdeaStorage_AddSupporter_ClosedIdea(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()diff --git a/app/storage/postgres/user.go b/app/storage/postgres/user.goindex 06369174d..6709b7485 100644--- a/app/storage/postgres/user.go+++ b/app/storage/postgres/user.go@@ -25,6 +25,10 @@ type dbUserProvider struct {}func (u *dbUser) toModel() *models.User {+ if u == nil {+ return nil+ }+user := &models.User{ID: int(u.ID.Int64),Name: u.Name.String,diff --git a/app/storage/storage.go b/app/storage/storage.goindex 55f5d6614..09eaa981c 100644--- a/app/storage/storage.go+++ b/app/storage/storage.go@@ -20,12 +20,14 @@ type Idea interface {GetByNumber(number int) (*models.Idea, error)GetCommentsByIdea(number int) ([]*models.Comment, error)GetAll() ([]*models.Idea, error)+ GetAllBasic() ([]*models.BasicIdea, error)Add(title, description string, userID int) (*models.Idea, error)Update(number int, title, description string) (*models.Idea, error)AddComment(number int, content string, userID int) (int, error)AddSupporter(number, userID int) errorRemoveSupporter(number, userID int) errorSetResponse(number int, text string, userID, status int) error+ MarkAsDuplicate(number, originalNumber, userID int) errorSupportedBy(userID int) ([]int, error)}diff --git a/migrations/201801031643_original_id.up.sql b/migrations/201801031643_original_id.up.sqlnew file mode 100644index 000000000..df554f1ca--- /dev/null+++ b/migrations/201801031643_original_id.up.sql@@ -0,0 +1 @@+ALTER TABLE ideas ADD original_id INT NULL REFERENCES ideas(id);diff --git a/package-lock.json b/package-lock.jsonindex 70bfbe277..4162de4e4 100644--- a/package-lock.json+++ b/package-lock.json@@ -32,9 +32,9 @@"dev": true},"@types/react": {- "version": "16.0.31",- "resolved": "https://registry.npmjs.org/@types/react/-/react-16.0.31.tgz",- "integrity": "sha512-ft7OuDGUo39e+9LGwUewf2RyEaNBOjWbHUmD5bzjNuSuDabccE/1IuO7iR0dkzLjVUKxTMq69E+FmKfbgBcfbQ==",+ "version": "16.0.34",+ "resolved": "https://registry.npmjs.org/@types/react/-/react-16.0.34.tgz",+ "integrity": "sha512-Ee66fX2qMsDnDq7sPnDtq1bGoo479j6Fo1BlSnne+L5rp6ndzBUgz72+MRNuN56zg9uuteRCkJAMdDJEX2Uqig==","dev": true},"@types/react-dom": {@@ -44,7 +44,7 @@"dev": true,"requires": {"@types/node": "8.5.2",- "@types/react": "16.0.31"+ "@types/react": "16.0.34"}},"@types/react-textarea-autosize": {@@ -53,7 +53,7 @@"integrity": "sha512-50W9dx8TlA1Z2ZemtXXCu5docRHRTvdzIMwMAA1PSzeoivPmPguh3PHQ9ibEkK4WczPecrZblvyZCrA2t5KKnA==","dev": true,"requires": {- "@types/react": "16.0.31"+ "@types/react": "16.0.34"}},"@types/selenium-webdriver": {diff --git a/package.json b/package.jsonindex 0bf03680a..72ac95d6c 100644--- a/package.json+++ b/package.json@@ -6,8 +6,8 @@"dependencies": {"jquery": "^3.2.1","markdown-it": "^8.4.0",- "react": "^16.1.1",- "react-dom": "^16.1.1",+ "react": "^16.2.0",+ "react-dom": "^16.2.0","react-textarea-autosize": "^5.2.1","semantic-ui-css": "^2.2.12"},@@ -16,7 +16,7 @@"@types/jquery": "^3.2.16","@types/markdown-it": "0.0.4","@types/mocha": "^2.2.44",- "@types/react": "^16.0.25",+ "@types/react": "^16.0.34","@types/react-dom": "^16.0.3","@types/react-textarea-autosize": "^4.3.1","@types/selenium-webdriver": "^3.0.8",diff --git a/public/components/ShowIdeaResponse.tsx b/public/components/ShowIdeaResponse.tsxindex 518fdd0ba..796bbd363 100644--- a/public/components/ShowIdeaResponse.tsx+++ b/public/components/ShowIdeaResponse.tsx@@ -7,6 +7,30 @@ interface IdeaResponseProps {response: IdeaResponse;}+const DuplicateDetails = (props: IdeaResponseProps): JSX.Element | null => {+ const original = props.response.original;+ if (!original) {+ return null;+ }+ const status = IdeaStatus.Get(original.status);++ return (+ <div className="content">+ <span>↪</span>+ <span title={status.title} className={`ui mini empty circular ${status.color} label`} />+ <a href={`/ideas/${original.number}/${original.slug}`}>{original.title}</a>+ </div>+ );+};++const StatusDetails = (props: IdeaResponseProps): JSX.Element => {+ return (+ <div className="content">+ <MultiLineText text={props.response.text} style="full" />+ </div>+ );+};+export const ShowIdeaResponse = (props: IdeaResponseProps): JSX.Element => {const status = IdeaStatus.Get(props.status);@@ -18,9 +42,7 @@ export const ShowIdeaResponse = (props: IdeaResponseProps): JSX.Element => {<span className="info"><Moment date={props.response.respondedOn} /></span>- <div className="content">- <MultiLineText text={props.response.text} style="full" />- </div>+ {status === IdeaStatus.Duplicate ? DuplicateDetails(props) : StatusDetails(props)}</div>);}diff --git a/public/models/idea.ts b/public/models/idea.tsindex 51d270729..539faeffc 100644--- a/public/models/idea.ts+++ b/public/models/idea.ts@@ -17,19 +17,30 @@ export interface Idea {ranking: number;}+export interface BasicIdea {+ id: number;+ number: number;+ slug: string;+ title: string;+ status: number;+ totalSupporters: number;+}+export class IdeaStatus {constructor(public value: number,public title: string,public slug: string,public show: boolean,public closed: boolean,+ public filterable: boolean,public color: string) { }- public static Open = new IdeaStatus(0, 'Open', 'open', false, false, '');- public static Planned = new IdeaStatus(4, 'Planned', 'planned', true, false, 'violet');- public static Started = new IdeaStatus(1, 'Started', 'started', true, false, 'blue');- public static Completed = new IdeaStatus(2, 'Completed', 'completed', true, true, 'green');- public static Declined = new IdeaStatus(3, 'Declined', 'declined', true, true, 'red');+ public static Open = new IdeaStatus(0, 'Open', 'open', false, false, false, '');+ public static Planned = new IdeaStatus(4, 'Planned', 'planned', true, false, true, 'violet');+ public static Started = new IdeaStatus(1, 'Started', 'started', true, false, true, 'blue');+ public static Completed = new IdeaStatus(2, 'Completed', 'completed', true, true, true, 'green');+ public static Declined = new IdeaStatus(3, 'Declined', 'declined', true, true, true, 'red');+ public static Duplicate = new IdeaStatus(5, 'Duplicate', 'duplicate', true, true, false, 'yellow');public static Get(value: number): IdeaStatus {for (const status of IdeaStatus.All) {@@ -45,7 +56,8 @@ export class IdeaStatus {IdeaStatus.Planned,IdeaStatus.Started,IdeaStatus.Completed,- IdeaStatus.Declined+ IdeaStatus.Duplicate,+ IdeaStatus.Declined,];}@@ -53,6 +65,12 @@ export interface IdeaResponse {user: User;text: string;respondedOn: Date;+ original?: {+ number: number;+ title: string;+ slug: string;+ status: number;+ };}export interface Comment {diff --git a/public/pages/site/HomePage/HomePage.tsx b/public/pages/site/HomePage/HomePage.tsxindex 9c07a32cc..71b7d7825 100644--- a/public/pages/site/HomePage/HomePage.tsx+++ b/public/pages/site/HomePage/HomePage.tsx@@ -60,113 +60,113 @@ const ListIdeaItem = (props: { idea: Idea, user?: CurrentUser, tags: Tag[] }) =>};export class HomePage extends React.Component<HomePageProps, HomePageState> {- private filter: HTMLDivElement;+ private filter: HTMLDivElement;- constructor(props: HomePageProps) {- super(props);+ constructor(props: HomePageProps) {+ super(props);- const search = page.getQueryString('q');- const tags = page.getQueryStringArray('t');- const activeFilter = window.location.hash.substring(1);- this.state = {- ideas: this.filterIdeas(activeFilter, search, tags),- showCount: defaultShowCount,- activeFilter,- searching: !!search,- search,- tags- };- }-- private containsAll(str: string, substrings: string[]): boolean {- for (let i = 0; i !== substrings.length; i++) {- if (str.indexOf(substrings[i]) === - 1) {- return false;- }- }- return true;- }+ const search = page.getQueryString('q');+ const tags = page.getQueryStringArray('t');+ const activeFilter = window.location.hash.substring(1);+ this.state = {+ ideas: this.filterIdeas(activeFilter, search, tags),+ showCount: defaultShowCount,+ activeFilter,+ searching: !!search,+ search,+ tags+ };+ }- private selectedTagsChanged(tags: string[]): void {- const ideas = this.filterIdeas(this.state.activeFilter, this.state.search, tags);- this.setState({- ideas,- tags,- });+ private containsAll(str: string, substrings: string[]): boolean {+ for (let i = 0; i !== substrings.length; i++) {+ if (str.indexOf(substrings[i]) === - 1) {+ return false;+ }}+ return true;+ }- private filterIdeas(activeFilter: string, search: string | undefined, tags: string[]): Idea[] {- let path = '';- let ideas = [];-- if (search) {- const s = search.trim().toLowerCase();- path += `?q=${encodeURIComponent(s).replace(/%20/g, '+')}`;- ideas = this.props.ideas.filter((idea) => {- const terms = s.split(' ').filter((x) => x.length >= 2);- return (- this.containsAll(idea.title.toLowerCase(), terms) ||- this.containsAll(idea.description.toLowerCase(), terms) ||- (idea.response && this.containsAll(idea.response.text.toLowerCase(), terms))- );- });- } else {- path += activeFilter ? `#${activeFilter}` : '';- ideas = IdeaFilter.getFilter(activeFilter)(this.props.ideas);- }-- if (tags.length > 0) {- const prefix = (!path) ? '?' : '&';- path += `${prefix}t=${tags.join(',')}`;- }+ private selectedTagsChanged(tags: string[]): void {+ const ideas = this.filterIdeas(this.state.activeFilter, this.state.search, tags);+ this.setState({+ ideas,+ tags,+ });+ }- if (history.replaceState) {- const newUrl = page.getBaseUrl() + path;- window.history.replaceState({ path: newUrl }, '', newUrl);- }+ private filterIdeas(activeFilter: string, search: string | undefined, tags: string[]): Idea[] {+ let path = '';+ let ideas = [];- if (tags.length > 0) {- const tagsToFilter = this.props.tags.filter((x) => tags.indexOf(x.slug) >= 0).map((x) => x.id);- ideas = ideas.filter(- (i) => i.tags.filter(- (t) => tagsToFilter.indexOf(t) >= 0- ).length === tagsToFilter.length+ if (search) {+ const s = search.trim().toLowerCase();+ path += `?q=${encodeURIComponent(s).replace(/%20/g, '+')}`;+ ideas = this.props.ideas.filter((idea) => {+ const terms = s.split(' ').filter((x) => x.length >= 2);+ return (+ this.containsAll(idea.title.toLowerCase(), terms) ||+ this.containsAll(idea.description.toLowerCase(), terms) ||+ (idea.response && this.containsAll(idea.response.text.toLowerCase(), terms)));- }-- return ideas;- }-- private filterChanged(name: string) {- this.setState({- ideas: this.filterIdeas(name, this.state.search, this.state.tags),- showCount: defaultShowCount,- activeFilter: name,});+ } else {+ path += activeFilter ? `#${activeFilter}` : '';+ ideas = IdeaFilter.getFilter(activeFilter)(this.props.ideas);}- private showMore(event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>): void {- event.preventDefault();- this.setState({- showCount: this.state.showCount + defaultShowCount- });+ if (tags.length > 0) {+ const prefix = (!path) ? '?' : '&';+ path += `${prefix}t=${tags.join(',')}`;}- private resetSearch() {- this.setState({- search: '',- searching: false,- ideas: this.filterIdeas(this.state.activeFilter, '', this.state.tags),- });+ if (history.replaceState) {+ const newUrl = page.getBaseUrl() + path;+ window.history.replaceState({ path: newUrl }, '', newUrl);}- private searchIdea(input: string): void {- this.setState({- search: input,- ideas: this.filterIdeas(this.state.activeFilter, input, this.state.tags)- });+ if (tags.length > 0) {+ const tagsToFilter = this.props.tags.filter((x) => tags.indexOf(x.slug) >= 0).map((x) => x.id);+ ideas = ideas.filter(+ (i) => i.tags.filter(+ (t) => tagsToFilter.indexOf(t) >= 0+ ).length === tagsToFilter.length+ );}+ return ideas;+ }++ private filterChanged(name: string) {+ this.setState({+ ideas: this.filterIdeas(name, this.state.search, this.state.tags),+ showCount: defaultShowCount,+ activeFilter: name,+ });+ }++ private showMore(event: React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>): void {+ event.preventDefault();+ this.setState({+ showCount: this.state.showCount + defaultShowCount+ });+ }++ private resetSearch() {+ this.setState({+ search: '',+ searching: false,+ ideas: this.filterIdeas(this.state.activeFilter, '', this.state.tags),+ });+ }++ private searchIdea(input: string): void {+ this.setState({+ search: input,+ ideas: this.filterIdeas(this.state.activeFilter, input, this.state.tags)+ });+ }+public render() {const ideasToList = this.state.ideas.slice(0, this.state.showCount);diff --git a/public/pages/site/HomePage/IdeaFilter.tsx b/public/pages/site/HomePage/IdeaFilter.tsxindex 9fb185924..3033c79a6 100644--- a/public/pages/site/HomePage/IdeaFilter.tsx+++ b/public/pages/site/HomePage/IdeaFilter.tsx@@ -76,7 +76,7 @@ export class IdeaFilter extends React.Component<IdeaFilterProps, {}> {return group;}, {});- const statusFilterItems = IdeaStatus.All.filter((s) => s.show && grouped[s.value]).map((s) => (+ const statusFilterItems = IdeaStatus.All.filter((s) => s.filterable && grouped[s.value]).map((s) => (<div key={s.value} className={`item ${activeFilter === s.slug && 'active'}`} data-value={s.slug} data-text={s.title.toLowerCase()}>{s.title}<a className="ui mini circular label">{grouped[s.value]}</a>diff --git a/public/pages/site/ShowIdeaPage/IdeaSearch.tsx b/public/pages/site/ShowIdeaPage/IdeaSearch.tsxnew file mode 100644index 000000000..568510c9e--- /dev/null+++ b/public/pages/site/ShowIdeaPage/IdeaSearch.tsx@@ -0,0 +1,67 @@+import * as React from 'react';+import { BasicIdea, IdeaStatus } from '@fider/models';+import { actions } from '@fider/services';++interface IdeaSearchProps {+ exclude?: number[];+ onChanged(ideaNumber: number): void;+}++interface IdeaSearchState {+ ideas?: BasicIdea[];+}++export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchState> {+ private element: HTMLDivElement;++ constructor(props: IdeaSearchProps) {+ super(props);+ this.state = { };+ actions.getIdeas().then((res) => {+ const ideas = this.props.exclude && this.props.exclude.length > 0+ ? res.data.filter((i) => this.props.exclude!.indexOf(i.number) === -1)+ : res.data;+ this.setState({ ideas });+ });+ }++ public componentDidUpdate() {+ $(this.element).dropdown({+ fullTextSearch: true,+ onChange: (ideaNumber: string) => {+ if (ideaNumber) {+ this.props.onChanged(parseInt(ideaNumber, 10));+ }+ }+ });+ }++ public render() {+ const items = this.state.ideas && (+ <div className="menu">+ {this.state.ideas.map((i) => {+ const status = IdeaStatus.Get(i.status);+ return (+ <div key={i.id} className="item" data-value={i.number} data-text={i.title}>+ <span className="support"><i className="medium caret up icon" />{i.totalSupporters}</span>+ <span className={`ui mini label ${status.color}`}>+ {status.title}+ </span>+ {i.title}+ </div>+ );+ })}+ </div>+ );++ const className = `ui selection ${items ? 'search' : 'loading'} fluid dropdown fdr-idea-search`;++ return (+ <div className={className} ref={(e) => this.element = e!}>+ <i className="dropdown icon" />+ <div className="default text">Search original idea</div>+ {items}+ </div>+ );+ }+}diff --git a/public/pages/site/ShowIdeaPage/ResponseForm.tsx b/public/pages/site/ShowIdeaPage/ResponseForm.tsxindex 3ad6c308b..b0e7b4e2b 100644--- a/public/pages/site/ShowIdeaPage/ResponseForm.tsx+++ b/public/pages/site/ShowIdeaPage/ResponseForm.tsx@@ -2,6 +2,7 @@ import * as React from 'react';import { User, Comment, Idea, IdeaStatus } from '@fider/models';import { Button, DisplayError, Textarea } from '@fider/components/common';+import { IdeaSearch } from './';import { actions, Failure } from '@fider/services';@@ -12,6 +13,7 @@ interface ResponseFormProps {interface ResponseFormState {status: number;text: string;+ originalNumber: number;error?: Failure;}@@ -23,12 +25,13 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseForthis.state = {status: this.props.idea.status,+ originalNumber: 0,text: this.props.idea.response && this.props.idea.response.text};}private async submit() {- const result = await actions.setResponse(this.props.idea.number, this.state.status, this.state.text);+ const result = await actions.respond(this.props.idea.number, this.state);if (result.ok) {location.reload();} else {@@ -56,7 +59,7 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor);const modal = (- <div className="ui form modal" ref={(e) => this.modal = e!}>+ <div className="ui form modal fdr-response-form" ref={(e) => this.modal = e!}><div className="content"><DisplayError fields={['status']} error={this.state.error} /><div className="two fields">@@ -71,14 +74,28 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor</select></div></div>- <DisplayError fields={['text']} error={this.state.error} />- <div className="field">- <Textarea- onChange={(e) => this.setState({ text: e.currentTarget.value })}- defaultValue={this.state.text}- placeholder="What's going on with this idea? Let your users know what are your plans..."- />- </div>+ {+ this.state.status === IdeaStatus.Duplicate.value+ ?+ <>+ <DisplayError fields={['originalNumber']} error={this.state.error} />+ <IdeaSearch+ exclude={[this.props.idea.number]}+ onChanged={(originalNumber) => this.setState({ originalNumber })}+ />+ <span className="info">Votes from this idea will be merged into original idea.</span>+ </>+ : <>+ <DisplayError fields={['text']} error={this.state.error} />+ <div className="field">+ <Textarea+ onChange={(e) => this.setState({ text: e.currentTarget.value })}+ defaultValue={this.state.text}+ placeholder="What's going on with this idea? Let your users know what are your plans..."+ />+ </div>+ </>+ }</div><div className="actions">diff --git a/public/pages/site/ShowIdeaPage/ShowIdeaPage.scss b/public/pages/site/ShowIdeaPage/ShowIdeaPage.scssindex a209e1b03..dd662637c 100644--- a/public/pages/site/ShowIdeaPage/ShowIdeaPage.scss+++ b/public/pages/site/ShowIdeaPage/ShowIdeaPage.scss@@ -88,4 +88,21 @@}}}+}++.fdr-response-form {+ .fdr-idea-search {+ .support {+ text-align: center;+ width: 50px;+ display: inline-block;+ i {+ margin: 0;+ }+ }+ .label {+ width: 60px;+ text-align: center;+ }+ }}\ No newline at end of filediff --git a/public/pages/site/ShowIdeaPage/index.ts b/public/pages/site/ShowIdeaPage/index.tsindex a3ceca324..e97a2cdb2 100644--- a/public/pages/site/ShowIdeaPage/index.ts+++ b/public/pages/site/ShowIdeaPage/index.ts@@ -2,4 +2,5 @@ export * from './ShowIdeaPage';export * from './CommentInput';export * from './ResponseForm';export * from './CommentList';+export * from './IdeaSearch';export * from './TagsPanel';diff --git a/public/router.tsx b/public/router.tsxindex 323d61fc4..3889526fb 100644--- a/public/router.tsx+++ b/public/router.tsx@@ -19,15 +19,15 @@ interface PageConfiguration {const route = (path: string, component: any, id: string, showHeader: boolean): PageConfiguration => {path = path.replace('/', '\/').replace(':number', '\\d+')- .replace('*', '.*');+ .replace('*', '\/?.*');const regex = new RegExp(`^${path}$`);return { regex, component, id, showHeader };};const pathRegex = [- route('/', HomePage, 'fdr-home-page', true),- route('/ideas/:number/*', ShowIdeaPage, 'fdr-show-idea-page', true),+ route('', HomePage, 'fdr-home-page', true),+ route('/ideas/:number*', ShowIdeaPage, 'fdr-show-idea-page', true),route('/admin/members', MembersPage, 'fdr-admin-members-page', true),route('/admin/tags', ManageTagsPage, 'fdr-admin-tags-page', true),route('/admin', AdminHomePage, 'fdr-admin-page', true),@@ -37,6 +37,9 @@ const pathRegex = [];export const resolveRootComponent = (path: string): PageConfiguration => {+ if (path.length > 0 && path.charAt(path.length - 1) === '/') {+ path = path.substring(0, path.length - 1);+ }for (const entry of pathRegex) {if (entry.regex.test(path)) {return entry;diff --git a/public/services/actions/idea.ts b/public/services/actions/idea.tsindex 42f640a35..cb690ff7e 100644--- a/public/services/actions/idea.ts+++ b/public/services/actions/idea.ts@@ -1,5 +1,9 @@import { http, Result } from '@fider/services';-import { Idea } from '@fider/models';+import { Idea, BasicIdea } from '@fider/models';++export const getIdeas = async (): Promise<Result<BasicIdea[]>> => {+ return await http.get<BasicIdea[]>('/api/ideas');+};export const addSupport = async (ideaNumber: number): Promise<Result> => {return http.post(`/api/ideas/${ideaNumber}/support`).then(http.event('idea', 'support'));@@ -13,8 +17,18 @@ export const createComment = async (ideaNumber: number, content: string): Promisreturn http.post(`/api/ideas/${ideaNumber}/comments`, { content }).then(http.event('comment', 'create'));};-export const setResponse = async (ideaNumber: number, status: number, text: string): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/status`, { status, text }).then(http.event('idea', 'respond'));+interface SetResponseInput {+ status: number;+ text: string;+ originalNumber: number;+}++export const respond = async (ideaNumber: number, input: SetResponseInput): Promise<Result> => {+ return http.post(`/api/ideas/${ideaNumber}/status`, {+ status: input.status,+ text: input.text,+ originalNumber: input.originalNumber,+ }).then(http.event('idea', 'respond'));};export const createIdea = async (title: string, description: string): Promise<Result<Idea>> => {diff --git a/public/services/http.ts b/public/services/http.tsindex 65b024e62..5f38acd65 100644--- a/public/services/http.ts+++ b/public/services/http.ts@@ -32,9 +32,10 @@ async function toResult<T>(response: Response): Promise<Result<T>> {}}async function request<T>(url: string, method: 'GET' | 'POST' | 'DELETE', body?: any): Promise<Result<T>> {- const headers = [[- 'Content-Type', 'application/json'- ]];+ const headers = [+ [ 'Accept', 'application/json' ],+ [ 'Content-Type', 'application/json' ]+ ];const response = await fetch(url, { method, headers, body: JSON.stringify(body), credentials: 'same-origin' });return await toResult<T>(response);}diff --git a/routes.go b/routes.goindex 59b151799..b6f018aaf 100644--- a/routes.go+++ b/routes.go@@ -99,6 +99,7 @@ func GetMainEngine(settings *models.AppSettings) *web.Engine {private.Use(middlewares.IsAuthenticated())private.Get("/settings", handlers.Page())+ private.Get("/api/ideas", handlers.GetIdeas())private.Post("/api/ideas", handlers.PostIdea())private.Post("/api/ideas/:number", handlers.UpdateIdea())private.Post("/api/ideas/:number/comments", handlers.PostComment())diff --git a/scripts/e2e.sh b/scripts/e2e.shindex e3b90803d..f84040251 100755--- a/scripts/e2e.sh+++ b/scripts/e2e.sh@@ -1,6 +1,7 @@#!/bin/bash-CONTAINER="fider_pge2e"+FIDER_CONTAINER="fider_e2e"+PG_CONTAINER="fider_pge2e"PORT=3000if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null ; then@@ -10,16 +11,17 @@ fiecho "Clean up ..."rm -rf output+docker rm -f $PG_CONTAINER || true+docker run -d -e POSTGRES_USER=fider_e2e -e POSTGRES_PASSWORD=fider_e2e_pw --name $PG_CONTAINER postgres:9.6.2++echo "Building ..."tsc-mkdir -p logs/-docker rm -f $CONTAINER || true-docker run -d -e POSTGRES_USER=fider_e2e -e POSTGRES_PASSWORD=fider_e2e_pw -p 5577:5432 --name $CONTAINER postgres:9.6.2-docker run --link $CONTAINER -e TARGETS=$CONTAINER:5432 waisbrot/wait+CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build+docker build -t getfider/fider:e2e .run_e2e () {echo "Starting Fider (HOST_MODE: $1)..."- HOST_MODE=$1 DATABASE_URL=postgres://fider_e2e:fider_e2e_pw@localhost:5577/fider_e2e?sslmode=disable godotenv -f .env ./fider > logs/e2e.log 2>&1 &- FIDER_PID=$!+ docker run -d -p 3000:3000 --link $PG_CONTAINER -e HOST_MODE=$1 -e DATABASE_URL=postgres://fider_e2e:fider_e2e_pw@$PG_CONTAINER:5432/fider_e2e?sslmode=disable --env-file .env --name $FIDER_CONTAINER getfider/fider:e2e{{@@ -29,13 +31,13 @@ run_e2e () {echo "Tests failed...";}} && {- echo "Killing Fider -> $FIDER_PID ..."- kill $(ps -ef | grep $FIDER_PID | grep -v grep | awk '{print $2}')+ echo "Stopping Fider ..."+ docker rm -f $FIDER_CONTAINER}}run_e2e singlerun_e2e multi-echo "Killing Container -> $CONTAINER ..."-docker rm -f $CONTAINER || true\ No newline at end of file+echo "Stopping Postgres ..."+docker rm -f $PG_CONTAINER || true\ No newline at end of file