浏览代码

fixed stats to report calories only for today

bmallred 10 年之前
父节点
当前提交
2ddd4bb03d
共有 3 个文件被更改,包括 53 次插入47 次删除
  1. 9 3
      app/controllers/profile.go
  2. 19 19
      app/routes/routes.go
  3. 25 25
      app/tmp/main.go

+ 9 - 3
app/controllers/profile.go

106
        return c.RenderJson(nil)
106
        return c.RenderJson(nil)
107
    }
107
    }
108
108
109
    now := time.Now().Local()
109
    history := c.getHistory(account)
110
    history := c.getHistory(account)
110
    current := int64(0)
111
    current := int64(0)
111
112
112
    if history != nil {
113
    if history != nil {
113
        for i := 0; i < len(history); i++ {
114
            if history[i] != nil {
115
                current += history[i].Calories
114
        for _, moment := range history {
115
            if moment != nil {
116
                utcMoment := moment.Date.Local()
117
                if utcMoment.Day() == now.Day() && utcMoment.Month() == now.Month() && utcMoment.Year() == now.Year() {
118
                    revel.INFO.Println(utcMoment)
119
                    revel.INFO.Println(now)
120
                    current += moment.Calories
121
                }
116
            }
122
            }
117
        }
123
        }
118
    }
124
    }

+ 19 - 19
app/routes/routes.go

94
94
95
95
96
96
97
type tHome struct {}
98
var Home tHome
99
100
101
func (_ tHome) Index(
102
		) string {
103
	args := make(map[string]string)
104
	
105
	return revel.MainRouter.Reverse("Home.Index", args).Url
106
}
107
108
func (_ tHome) About(
109
		) string {
110
	args := make(map[string]string)
111
	
112
	return revel.MainRouter.Reverse("Home.About", args).Url
113
}
114
115
116
type tProfile struct {}
97
type tProfile struct {}
117
var Profile tProfile
98
var Profile tProfile
118
99
177
}
158
}
178
159
179
160
161
type tHome struct {}
162
var Home tHome
163
164
165
func (_ tHome) Index(
166
		) string {
167
	args := make(map[string]string)
168
	
169
	return revel.MainRouter.Reverse("Home.Index", args).Url
170
}
171
172
func (_ tHome) About(
173
		) string {
174
	args := make(map[string]string)
175
	
176
	return revel.MainRouter.Reverse("Home.About", args).Url
177
}
178
179

+ 25 - 25
app/tmp/main.go

118
			
118
			
119
		})
119
		})
120
	
120
	
121
	revel.RegisterController((*controllers.Home)(nil),
122
		[]*revel.MethodType{
123
			&revel.MethodType{
124
				Name: "Index",
125
				Args: []*revel.MethodArg{ 
126
				},
127
				RenderArgNames: map[int][]string{ 
128
					12: []string{ 
129
					},
130
				},
131
			},
132
			&revel.MethodType{
133
				Name: "About",
134
				Args: []*revel.MethodArg{ 
135
				},
136
				RenderArgNames: map[int][]string{ 
137
					16: []string{ 
138
					},
139
				},
140
			},
141
			
142
		})
143
	
144
	revel.RegisterController((*controllers.Profile)(nil),
121
	revel.RegisterController((*controllers.Profile)(nil),
145
		[]*revel.MethodType{
122
		[]*revel.MethodType{
146
			&revel.MethodType{
123
			&revel.MethodType{
202
			
179
			
203
		})
180
		})
204
	
181
	
182
	revel.RegisterController((*controllers.Home)(nil),
183
		[]*revel.MethodType{
184
			&revel.MethodType{
185
				Name: "Index",
186
				Args: []*revel.MethodArg{ 
187
				},
188
				RenderArgNames: map[int][]string{ 
189
					12: []string{ 
190
					},
191
				},
192
			},
193
			&revel.MethodType{
194
				Name: "About",
195
				Args: []*revel.MethodArg{ 
196
				},
197
				RenderArgNames: map[int][]string{ 
198
					16: []string{ 
199
					},
200
				},
201
			},
202
			
203
		})
204
	
205
	revel.DefaultValidationKeys = map[string]map[int]string{ 
205
	revel.DefaultValidationKeys = map[string]map[int]string{ 
206
		"github.com/revolvingcow/grassfed/app/controllers.Profile.Add": { 
206
		"github.com/revolvingcow/grassfed/app/controllers.Profile.Add": { 
207
			134: "product",
208
			135: "calories",
207
			140: "product",
208
			141: "calories",
209
		},
209
		},
210
		"github.com/revolvingcow/grassfed/app/controllers.Profile.Logon": { 
210
		"github.com/revolvingcow/grassfed/app/controllers.Profile.Logon": { 
211
			60: "id",
211
			60: "id",