Skip to content

Commit ff931a9

Browse files
committed
feat: reducing duration for disk space optimization
1 parent 88eefe0 commit ff931a9

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

rec/rec_iqama.go

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
)
99

1010
var (
11-
EveryDay []time.Weekday = []time.Weekday{time.Sunday, time.Monday, time.Tuesday, time.Wednesday, time.Thursday, time.Friday, time.Saturday}
11+
EveryDayButFriday []time.Weekday = []time.Weekday{time.Sunday, time.Monday, time.Tuesday, time.Wednesday, time.Thursday, time.Saturday}
1212
JumuaaRecordDuration time.Duration = 2 * time.Hour
13-
DarsRecordDuration time.Duration = 45 * time.Minute
13+
DarsRecordDuration time.Duration = 35 * time.Minute
1414
location string = "America/Montreal"
1515
)
1616

@@ -20,15 +20,18 @@ type RecordConfigDataS struct {
2020
mu sync.Mutex
2121
}
2222

23+
// NewRecordConfigDataS TODO: temporarily in code but needs to move to the postgresql db from the robot-api project
2324
func NewRecordConfigDataS() *RecordConfigDataS {
2425
iqamaClient := v2.NewIqamaCSV("iqama_2025.csv")
2526
today, err := iqamaClient.GetTodayTimes()
2627
if err != nil {
2728
fmt.Println("couldn't fetch iqama times, keeping current data")
29+
return nil
2830
}
2931

3032
if today == nil {
31-
33+
fmt.Println("couldn't fetch iqama times, keeping current data")
34+
return nil
3235
}
3336

3437
fajr := today.Fajr.Iqama
@@ -48,26 +51,25 @@ func NewRecordConfigDataS() *RecordConfigDataS {
4851
Description: "Fajr Recording",
4952
StartTime: fajr,
5053
Duration: DarsRecordDuration,
51-
RecordingDays: EveryDay,
54+
RecordingDays: EveryDayButFriday,
5255
},
5356
{
5457
Description: "Dhuhur Recording",
5558
StartTime: dhuhr,
5659
Duration: DarsRecordDuration,
57-
RecordingDays: EveryDay,
60+
RecordingDays: EveryDayButFriday,
5861
},
5962
{
6063
Description: "Maghrib Recording Sunday",
6164
StartTime: maghrib,
62-
Duration: JumuaaRecordDuration,
65+
Duration: isha.Add(-5 * time.Minute).Sub(maghrib),
6366
RecordingDays: []time.Weekday{time.Sunday},
6467
},
65-
6668
{
6769
Description: "Isha Recording",
6870
StartTime: isha,
6971
Duration: DarsRecordDuration,
70-
RecordingDays: EveryDay,
72+
RecordingDays: EveryDayButFriday,
7173
},
7274
},
7375
}
@@ -134,19 +136,6 @@ func SupposedToBeRecording(data *RecordConfigDataS) bool {
134136
return shouldRecord
135137
}
136138

137-
func GetIqamaRecordingConfigs() {
138-
139-
}
140-
141-
func toTime(s string) time.Time {
142-
t, err := time.Parse("15:04", s)
143-
if err != nil {
144-
panic(fmt.Sprintf("could not parse prayer time %s, %s", s, err.Error()))
145-
}
146-
fmt.Println(timeToday(t.Hour(), t.Minute()))
147-
return timeToday(t.Hour(), t.Minute())
148-
}
149-
150139
func timeToday(hour, minute int) time.Time {
151140
now := time.Now()
152141

rec/server.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,8 @@ func StartRecServer(host, password string) (*Recorder, error) {
3232
}
3333
}
3434

35-
var recordTimeLimit float64
36-
{
37-
recordTimeLimit = 2 * 60 * 60 * 1000
38-
}
39-
4035
// Stop recording if not supposed to be recording but currently recording
41-
if !shouldRecord && isRecording && (client.RecordTime() > recordTimeLimit) {
36+
if !shouldRecord && isRecording {
4237
err := client.StopRecording()
4338
if err != nil {
4439
fmt.Println("couldn't stop recording")

0 commit comments

Comments
 (0)