func (repo *RepositoryConfig) Recents(camera string) (recents []*Image, saved []*Image, generated []*Image, motion []*Image) {
	TAG := "RepositoryConfig.Recents"

	cam := System.GetCamera(camera)
	if cam == nil {
		panic(fmt.Errorf("unknown camera '%s'", camera))
	}

	for _, kind := range AllKinds {
		for _, img := range repo.ListKind(camera, kind) {
			switch kind {
			case MediaMotion:
				motion = append(motion, img)
				fallthrough
			case MediaCollected: // recents is a *mix* of collected + motion
				recents = append(recents, img)
			case MediaGenerated:
				generated = append(generated, img)
			case MediaSaved:
				saved = append(saved, img)
			default:
				log.Warn(TAG, "unknown media kind?!", kind)
			}
		}
	}

	// note that these need to be sorted in descending order by date, so the comparator is backward
	sort.Slice(recents, func(i, j int) bool { return recents[i].Timestamp.After(recents[j].Timestamp) })
	sort.Slice(saved, func(i, j int) bool { return saved[i].Timestamp.After(saved[j].Timestamp) })
	sort.Slice(generated, func(i, j int) bool { return generated[i].Timestamp.After(generated[j].Timestamp) })
	sort.Slice(motion, func(i, j int) bool { return motion[i].Timestamp.After(motion[j].Timestamp) })

	if len(recents) > 7 {
		recents = recents[:7]
	}
	if len(saved) > 4 {
		saved = saved[:4]
	}
	if len(motion) > 4 {
		motion = motion[:4]
	}
	if len(generated) > 4 {
		generated = generated[:4]
	}

	return
}
// Recents returns recent photo activity. It will return up to 7 most recent
// images (collected or motion), and up to 4 most recent of the others.
Recents returns recent photo activity. It will return up to 7 most recent
images (collected or motion), and up to 4 most recent of the others.
// Recents returns recent photo activity . It will return up to 7 most recent // images ( collected or motion ) and up to 4 most recent of the others .
func (repo *RepositoryConfig) Recents(camera string) (recents []*Image, saved []*Image, generated []*Image, motion []*Image) {
	TAG := "RepositoryConfig.Recents"
	cam := System.GetCamera(camera)
	if cam == nil {
		panic(fmt.Errorf("unknown camera '%s'", camera))
	}
	for _, kind := range AllKinds {
		for _, img := range repo.ListKind(camera, kind) {
			switch kind {
			case MediaMotion:
				motion = append(motion, img)
				fallthrough
			case MediaCollected: 
				recents = append(recents, img)
			case MediaGenerated:
				generated = append(generated, img)
			case MediaSaved:
				saved = append(saved, img)
			default:
				log.Warn(TAG, "unknown media kind?!", kind)
			}
		}
	}
	sort.Slice(recents, func(i, j int) bool { return recents[i].Timestamp.After(recents[j].Timestamp) })
	sort.Slice(saved, func(i, j int) bool { return saved[i].Timestamp.After(saved[j].Timestamp) })
	sort.Slice(generated, func(i, j int) bool { return generated[i].Timestamp.After(generated[j].Timestamp) })
	sort.Slice(motion, func(i, j int) bool { return motion[i].Timestamp.After(motion[j].Timestamp) })
	if len(recents) > 7 {
		recents = recents[:7]
	}
	if len(saved) > 4 {
		saved = saved[:4]
	}
	if len(motion) > 4 {
		motion = motion[:4]
	}
	if len(generated) > 4 {
		generated = generated[:4]
	}
	return
}
func ( repo * RepositoryConfig ) Recents ( camera string ) ( recents [ ] * Image , saved [ ] * Image , generated [ ] * Image , motion [ ] * Image ) { TAG := " " cam := System . GetCamera ( camera ) if cam == nil { panic ( fmt . Errorf ( " " , camera ) ) } for _ , kind := range AllKinds { for _ , img := range repo . ListKind ( camera , kind ) { switch kind { case MediaMotion : motion = append ( motion , img ) fallthrough case MediaCollected : recents = append ( recents , img ) case MediaGenerated : generated = append ( generated , img ) case MediaSaved : saved = append ( saved , img ) default : log . Warn ( TAG , " " , kind ) } } } sort . Slice ( recents , func ( i , j int ) bool { return recents [ i ] . Timestamp . After ( recents [ j ] . Timestamp ) } ) sort . Slice ( saved , func ( i , j int ) bool { return saved [ i ] . Timestamp . After ( saved [ j ] . Timestamp ) } ) sort . Slice ( generated , func ( i , j int ) bool { return generated [ i ] . Timestamp . After ( generated [ j ] . Timestamp ) } ) sort . Slice ( motion , func ( i , j int ) bool { return motion [ i ] . Timestamp . After ( motion [ j ] . Timestamp ) } ) if len ( recents ) > 7 { recents = recents [ : 7 ] } if len ( saved ) > 4 { saved = saved [ : 4 ] } if len ( motion ) > 4 { motion = motion [ : 4 ] } if len ( generated ) > 4 { generated = generated [ : 4 ] } return }
Recents returns recent photo activity.
Recents returns recent photo activity .
// recents is a *mix* of collected + motion // note that these need to be sorted in descending order by date, so the comparator is backward