From 24630e0c9b92bcd9fdeb07ce15c3dd2cfc459a52 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 23 Mar 2014 18:00:09 +0800 Subject: [PATCH] improved activity --- models/action.go | 7 ++++++- serve.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/models/action.go b/models/action.go index 4f78deb30..ca2ff3cbf 100644 --- a/models/action.go +++ b/models/action.go @@ -51,9 +51,14 @@ func (a Action) GetContent() string { return a.Content } +type PushCommits struct { + Len int + Commits [][]string +} + // CommitRepoAction records action for commit repository. func CommitRepoAction(userId int64, userName string, - repoId int64, repoName string, refName string, commits [][]string) error { + repoId int64, repoName string, refName string, commits *PushCommits) error { bs, err := json.Marshal(commits) if err != nil { return err diff --git a/serve.go b/serve.go index 812c37bb5..71abf5fdd 100644 --- a/serve.go +++ b/serve.go @@ -262,7 +262,7 @@ func runServ(k *cli.Context) { } commits := make([][]string, 0) - var maxCommits = 5 + var maxCommits = 3 for e := l.Back(); e != nil; e = e.Prev() { commit := e.Value.(*git.Commit) commits = append(commits, []string{commit.Id().String(), commit.Message()}) @@ -272,7 +272,7 @@ func runServ(k *cli.Context) { } if err = models.CommitRepoAction(user.Id, user.Name, - repo.Id, repoName, refname, commits); err != nil { + repo.Id, repoName, refname, &models.PushCommits{l.Len(), commits}); err != nil { log.Error("runUpdate.models.CommitRepoAction: %v", err, commits) } else { //log.Info("refname", refname)