MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Lists

Method Lists

models/ads.go:249–274  ·  view source on GitHub ↗
(isMobile bool, status ...bool)

Source from the content-addressed store, hash-verified

247}
248
249func (m *AdsCont) Lists(isMobile bool, status ...bool) (ads []AdsCont) {
250 var (
251 positions []AdsPosition
252 pids []interface{}
253 tablePosition = NewAdsPosition()
254 tableAds = NewAdsCont()
255 )
256 o := orm.NewOrm()
257 o.QueryTable(tablePosition).Filter("is_mobile", isMobile).All(&positions)
258 for _, p := range positions {
259 pids = append(pids, p.Id)
260 }
261
262 q := o.QueryTable(tableAds).Filter("pid__in", pids...)
263 if len(status) > 0 {
264 q = q.Filter("status", status[0])
265 }
266 q.All(&ads)
267 layout := "2006-01-02"
268 for idx, ad := range ads {
269 ad.StartTime = time.Unix(int64(ad.Start), 0).Format(layout)
270 ad.EndTime = time.Unix(int64(ad.End), 0).Format(layout)
271 ads[idx] = ad
272 }
273 return
274}
275
276func GetAdsCode(positionIdentify string, isMobile bool) (code string) {
277 if beego.AppConfig.String("runmode") == "dev" {

Callers

nothing calls this directly

Calls 4

NewAdsPositionFunction · 0.85
NewAdsContFunction · 0.85
appendFunction · 0.50
AllMethod · 0.45

Tested by

no test coverage detected