Skip to content

Commit 62365c7

Browse files
author
Stefan Vitanov
committed
in progress
1 parent cb0d7bd commit 62365c7

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

core/logic_events.go

+29-7
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ func (e eventsLogic) setupWebToolsTimer() {
149149
now := time.Now().In(location)
150150
log.Printf("setupWebToolsTimer -> now - hours:%d minutes:%d seconds:%d\n", now.Hour(), now.Minute(), now.Second())
151151

152-
nowSecondsInDay := 60*60*now.Hour() + 60*now.Minute() + now.Second()
153-
desiredMoment := 18000
152+
//nowSecondsInDay := 60*60*now.Hour() + 60*now.Minute() + now.Second()
153+
//desiredMoment := 18000
154154

155-
var durationInSeconds int
155+
/*var durationInSeconds int
156156
log.Printf("setupWebToolsTimer -> nowSecondsInDay:%d desiredMoment:%d\n", nowSecondsInDay, desiredMoment)
157157
if nowSecondsInDay <= desiredMoment {
158158
log.Println("setupWebToolsTimer -> not web tools process today, so the first process will be today")
@@ -161,10 +161,10 @@ func (e eventsLogic) setupWebToolsTimer() {
161161
log.Println("setupWebToolsTimer -> the web tools process has already been processed today, so the first process will be tomorrow")
162162
leftToday := 86400 - nowSecondsInDay
163163
durationInSeconds = leftToday + desiredMoment // the time which left today + desired moment from tomorrow
164-
}
164+
}*/
165165
//log.Println(durationInSeconds)
166-
//duration := time.Second * time.Duration(20)
167-
duration := time.Second * time.Duration(durationInSeconds)
166+
duration := time.Second * time.Duration(0)
167+
//duration := time.Second * time.Duration(durationInSeconds)
168168
log.Printf("setupWebToolsTimer -> first call after %s", duration)
169169

170170
e.dailyWebToolsTimer = time.NewTimer(duration)
@@ -455,11 +455,16 @@ func (e eventsLogic) constructLegacyEvents(g model.WebToolsEvent) model.LegacyEv
455455
outlookUrl := fmt.Sprintf("https://calendars.illinois.edu/outlook2010/%s/%s.ics", g.CalendarID, g.EventID)
456456

457457
recurrenceID, _ := recurenceIDtoInt(g.RecurrenceID)
458+
location := locationToDef(g.Location)
459+
con := model.ContactLegacy{ContactName: g.CalendarName, ContactEmail: g.ContactEmail, ContactPhone: g.ContactName}
460+
var contacts []model.ContactLegacy
461+
contacts = append(contacts, con)
462+
contatsLegacy := contactsToDef(contacts)
458463

459464
return model.LegacyEvent{Category: g.EventType, OriginatingCalendarID: g.OriginatingCalendarID, IsVirtial: isVirtual, DataModified: g.EventID,
460465
Sponsor: g.Sponsor, Title: g.Title, CalendarID: g.CalendarID, SourceID: "0", AllDay: false, IsEventFree: costFree, LongDescription: g.Description,
461466
TitleURL: g.TitleURL, RegistrationURL: g.RegistrationURL, RecurringFlag: Recurrence, IcalURL: icalUrl, OutlookURL: outlookUrl,
462-
RecurrenceID: recurrenceID}
467+
RecurrenceID: recurrenceID, Location: &location, Contacts: contatsLegacy}
463468
}
464469

465470
func recurenceIDtoInt(s string) (*int, error) {
@@ -476,6 +481,23 @@ func recurenceIDtoInt(s string) (*int, error) {
476481
return result, nil
477482
}
478483

484+
// Location
485+
func locationToDef(location string) model.LocationLegacy {
486+
return model.LocationLegacy{Description: location}
487+
}
488+
489+
// Contacts
490+
func contactToDef(items model.ContactLegacy) model.ContactLegacy {
491+
return model.ContactLegacy{ContactName: items.ContactName, ContactEmail: items.ContactEmail, ContactPhone: items.ContactPhone}
492+
}
493+
func contactsToDef(items []model.ContactLegacy) []model.ContactLegacy {
494+
defs := make([]model.ContactLegacy, len(items))
495+
for index := range items {
496+
defs[index] = contactToDef(items[index])
497+
}
498+
return defs
499+
}
500+
479501
// newAppEventsLogic creates new appShared
480502
func newAppEventsLogic(app *Application, eventsBBAdapter EventsBBAdapter, logger logs.Logger) eventsLogic {
481503
timerDone := make(chan bool)

core/model/legacyEvents.go

+8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type LegacyEvent struct {
123123
Title string `json:"title" bson:"title"`
124124
TitleURL string `json:"titleURL" bson:"titleURL"`
125125
RegistrationURL string `json:"registrationURL" bson:"registrationURL"`
126+
Contacts []ContactLegacy `json:"contacts" bson:"contacts"`
126127
SubEvents []SubEvents `json:"subEvents" bson:"subEvents"`
127128
}
128129

@@ -147,3 +148,10 @@ type LegacyEventItem struct {
147148

148149
Item LegacyEvent `bson:"item"`
149150
}
151+
152+
// ContactLegacy represents event legacy contacts
153+
type ContactLegacy struct {
154+
ContactName string `json:"contactName" bson:"contactName"`
155+
ContactEmail string `json:"contactEmail" bson:"contactEmail"`
156+
ContactPhone string `json:"contactPhone" bson:"contactPhone"`
157+
}

0 commit comments

Comments
 (0)