Esempio n. 1
0
//NeverLogged scan students that never logged in since
//one week before the beginning of the internship
func NeverLogged(provider schema.Internshipser, not *notifier.Notifier) {
	ints, err := provider.Internships()
	logger.Log("event", "cron", "Scanning the internships for student that never connected", err)
	if err != nil {
		return
	}
	for _, i := range ints {
		last := i.Convention.Student.User.LastVisit
		if last == nil && i.Convention.Begin.Before(time.Now()) {
			//The internship began
			not.ReportIdleAccount(i.Convention.Student.User)
		}
	}
}
Esempio n. 2
0
//MissingSurveys scans the missing surveys
//One week before the deadine, it send a first mail, then a reminder every week until the survey is uploaded
func MissingSurveys(provider schema.Internshipser, not *notifier.Notifier) {
	ints, err := provider.Internships()
	logger.Log("event", "cron", "Scanning the internships for surveys to request", err)
	if err != nil {
		return
	}

	now := time.Now()
	for _, i := range ints {
		if i.Convention.Skip {
			continue
		}
		for _, s := range i.Surveys {
			if s.Delivery == nil && s.Invitation.Before(now) {
				//Its time to notify the supervisor
				not.SurveyRequest(i.Convention.Supervisor, i.Convention.Tutor, i.Convention.Student, s, nil)
			}
		}
	}
}