示例#1
0
文件: idle.go 项目: fhermeni/wints
//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)
		}
	}
}
示例#2
0
文件: surveys.go 项目: fhermeni/wints
//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)
			}
		}
	}
}
示例#3
0
文件: reports.go 项目: fhermeni/wints
//MissingReports scan the internships for reports or reviews that are missing
func MissingReports(provider schema.Internshipser, not notifier.NewsLetter) {
	ints, err := provider.Internships()
	logger.Log("event", "cron", "Scanning the internships for the tutor newsletters", err)
	if err != nil {
		return
	}
	byTutor := make(map[string][]schema.StudentReports)
	tutors := make(map[string]schema.User)
	for _, i := range ints {
		if i.Convention.Skip {
			continue
		}
		student := i.Convention.Student
		em := i.Convention.Tutor.Person.Email
		reports, ok := byTutor[em]
		if !ok {
			reports = make([]schema.StudentReports, 0)
			tutors[em] = i.Convention.Tutor
		}
		lates := lateReports(i.Reports)
		if len(lates) > 0 {
			x := schema.StudentReports{
				Student: student,
				Reports: lates,
			}
			reports = append(reports, x)
		}

		byTutor[em] = reports
	}

	for em, lates := range byTutor {
		if len(lates) > 0 {
			not.TutorNewsLetter(tutors[em], lates)
		}
	}
}