Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 2fc5034

Browse files
committed
webui: Fork information is a database detail, not some meta information
This moves the fork information into the database details data structure and removes it from the meta data structure. The idea here is to be able to retrieve this information if and only if it is needed.
1 parent 0267245 commit 2fc5034

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

common/postgresql.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,12 @@ func DBDetails(DB *SQLiteDBinfo, loggedInUser, dbOwner, dbFolder, dbName, commit
668668
return err
669669
}
670670

671+
// Retrieve the "forked from" information
672+
DB.Info.ForkOwner, DB.Info.ForkFolder, DB.Info.ForkDatabase, DB.Info.ForkDeleted, err = ForkedFrom(dbOwner, dbFolder, dbName)
673+
if err != nil {
674+
return err
675+
}
676+
671677
return nil
672678
}
673679

common/types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ type DBInfo struct {
214214
Discussions int
215215
Downloads int
216216
Folder string
217+
ForkDatabase string
218+
ForkDeleted bool
219+
ForkFolder string
220+
ForkOwner string
217221
Forks int
218222
FullDesc string
219223
IsLive bool
@@ -343,13 +347,9 @@ type MergeRequestEntry struct {
343347
}
344348

345349
type MetaInfo struct {
346-
Database string
347-
Folder string
348-
ForkDatabase string
349-
ForkDeleted bool
350-
ForkFolder string
351-
ForkOwner string
352-
Owner string
350+
Database string
351+
Folder string
352+
Owner string
353353
}
354354

355355
type ReleaseEntry struct {

webui/main.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -379,20 +379,18 @@ func checkLogin(r *http.Request) (loggedInUser string, validSession bool, err er
379379
return
380380
}
381381

382-
func collectPageAuth0Info() (auth0 Auth0Set) {
383-
auth0.CallbackURL = "https://" + com.Conf.Web.ServerName + "/x/callback"
384-
auth0.ClientID = com.Conf.Auth0.ClientID
385-
auth0.Domain = com.Conf.Auth0.Domain
386-
return
387-
}
388-
389382
func collectPageMetaInfo(r *http.Request, pageMeta *PageMetaInfo, meta *com.MetaInfo, requireLogin bool, getOwnerAndDatabaseFromUrl bool, getOwnerAndDatabaseFromData bool) (errCode int, err error) {
390383
// Auth0 info
391-
pageMeta.Auth0 = collectPageAuth0Info()
384+
pageMeta.Auth0.CallbackURL = "https://" + com.Conf.Web.ServerName + "/x/callback"
385+
pageMeta.Auth0.ClientID = com.Conf.Auth0.ClientID
386+
pageMeta.Auth0.Domain = com.Conf.Auth0.Domain
392387

393388
// Server name
394389
pageMeta.Server = com.Conf.Web.ServerName
395390

391+
// Pass along the environment setting
392+
pageMeta.Environment = com.Conf.Environment.Environment
393+
396394
// Retrieve session data (if any)
397395
loggedInUser, validSession, err := checkLogin(r)
398396
if err != nil {
@@ -467,17 +465,8 @@ func collectPageMetaInfo(r *http.Request, pageMeta *PageMetaInfo, meta *com.Meta
467465
meta.Database = dbName
468466
meta.Owner = usr.Username
469467
meta.Folder = "/"
470-
471-
// Retrieve the "forked from" information
472-
meta.ForkOwner, meta.ForkFolder, meta.ForkDatabase, meta.ForkDeleted, err = com.ForkedFrom(meta.Owner, meta.Folder, meta.Database)
473-
if err != nil {
474-
return http.StatusBadRequest, err
475-
}
476468
}
477469

478-
// Pass along the environment setting
479-
pageMeta.Environment = com.Conf.Environment.Environment
480-
481470
return
482471
}
483472

webui/templates/script_db_header.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
licenceURL: "[[ .DB.Info.LicenceURL ]]",
1414
size: [[ .DB.Info.DBEntry.Size ]],
1515

16-
forkOwner: "[[ .Meta.ForkOwner ]]",
17-
forkDatabase: "[[ .Meta.ForkDatabase ]]",
18-
forkDeleted: [[ .Meta.ForkDeleted ]],
16+
forkOwner: "[[ .DB.Info.ForkOwner ]]",
17+
forkDatabase: "[[ .DB.Info.ForkDatabase ]]",
18+
forkDeleted: [[ .DB.Info.ForkDeleted ]],
1919
numForks: [[ .DB.Info.Forks ]],
2020

2121
commitID: "[[ .DB.Info.CommitID ]]",

0 commit comments

Comments
 (0)