Skip to content

Commit 0d89e6b

Browse files
committed
fix: modify code to fix lint error
1 parent add8d72 commit 0d89e6b

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

provider-middleware/brightspace.go

+1-14
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import (
77
"fmt"
88
"net/http"
99
"net/url"
10-
"os"
1110
"strings"
1211
"time"
1312

14-
"github.com/gocarina/gocsv"
1513
log "github.com/sirupsen/logrus"
1614
"gorm.io/gorm"
1715
)
@@ -143,7 +141,7 @@ func (srv *BrightspaceService) ImportCourses(db *gorm.DB) error {
143141

144142
//3. read CSV file and parse organizational units
145143
bsCourses := []BrightspaceCourse{}
146-
ReadCSV(&bsCourses, csvFile)
144+
readCSV(&bsCourses, csvFile)
147145
for _, bsCourse := range bsCourses {
148146
if bsCourse.IsActive == "TRUE" && bsCourse.IsDeleted == "FALSE" && bsCourse.Type == "Course Offering" {
149147
//total progress is going to be on hold for now
@@ -168,17 +166,6 @@ func (srv *BrightspaceService) ImportCourses(db *gorm.DB) error {
168166
return nil
169167
}
170168

171-
func ReadCSV[T any](values *T, csvFilePath string) {
172-
coursesFile, err := os.OpenFile(csvFilePath, os.O_RDWR|os.O_CREATE, os.ModePerm)
173-
if err != nil {
174-
panic(err)
175-
}
176-
defer coursesFile.Close()
177-
if err := gocsv.UnmarshalFile(coursesFile, values); err != nil { // Load clients from file
178-
panic(err)
179-
}
180-
}
181-
182169
func (srv *BrightspaceService) ImportMilestones(coursePair map[string]interface{}, mappings []map[string]interface{}, db *gorm.DB, lastRun time.Time) error {
183170
fmt.Println("ImportMilestones...")
184171
return nil

provider-middleware/brightspace_data.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import (
1010
"io"
1111
"mime/multipart"
1212
"net/http"
13-
"net/url"
1413
"os"
1514
"path/filepath"
15+
16+
"github.com/gocarina/gocsv"
1617
)
1718

1819
type DataSetPlugin struct {
@@ -82,8 +83,6 @@ func (srv *BrightspaceService) IntoCourse(bsCourse BrightspaceCourse) *models.Co
8283
imgPath = ""
8384
}
8485
}
85-
86-
externalUrl, err := url.JoinPath(srv.BaseURL, "")
8786
course := models.Course{
8887
ProviderPlatformID: srv.ProviderPlatformID,
8988
ExternalID: bsCourse.OrgUnitId,
@@ -93,7 +92,7 @@ func (srv *BrightspaceService) IntoCourse(bsCourse BrightspaceCourse) *models.Co
9392
TotalProgressMilestones: uint(0), //come back to this one
9493
Description: "Brightspace Course: " + bsCourse.Name,
9594
ThumbnailURL: imgPath,
96-
ExternalURL: externalUrl,
95+
ExternalURL: srv.BaseURL, //update this when the time comes
9796
}
9897

9998
fmt.Println("image path: ", imgPath)
@@ -222,3 +221,14 @@ func (srv *BrightspaceService) downloadAndUnzipFile(targetDirectory string, targ
222221
}
223222
return destPath, err
224223
}
224+
225+
func readCSV[T any](values *T, csvFilePath string) {
226+
coursesFile, err := os.OpenFile(csvFilePath, os.O_RDWR|os.O_CREATE, os.ModePerm)
227+
if err != nil {
228+
panic(err)
229+
}
230+
defer coursesFile.Close()
231+
if err := gocsv.UnmarshalFile(coursesFile, values); err != nil { // Load clients from file
232+
panic(err)
233+
}
234+
}

0 commit comments

Comments
 (0)