Skip to content

Commit

Permalink
Add implemntation to apply the age filter on the Usage Table
Browse files Browse the repository at this point in the history
  • Loading branch information
rk1274 committed Oct 25, 2024
1 parent 49a6360 commit ebac00a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 12 deletions.
53 changes: 49 additions & 4 deletions server/basedirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
gas "github.com/wtsi-hgi/go-authserver"
ifs "github.com/wtsi-hgi/wrstat-ui/internal/fs"
"github.com/wtsi-ssg/wrstat/v5/basedirs"

Check failure on line 38 in server/basedirs.go

View workflow job for this annotation

GitHub Actions / test

github.com/wtsi-ssg/wrstat/v5@v5.0.0: replacement directory /nfs/users/nfs_r/rk18/src/wrstat does not exist
"github.com/wtsi-ssg/wrstat/v5/summary"

Check failure on line 39 in server/basedirs.go

View workflow job for this annotation

GitHub Actions / test

github.com/wtsi-ssg/wrstat/v5@v5.0.0: replacement directory /nfs/users/nfs_r/rk18/src/wrstat does not exist
"github.com/wtsi-ssg/wrstat/v5/watch"

Check failure on line 40 in server/basedirs.go

View workflow job for this annotation

GitHub Actions / test

github.com/wtsi-ssg/wrstat/v5@v5.0.0: replacement directory /nfs/users/nfs_r/rk18/src/wrstat does not exist
)

Expand Down Expand Up @@ -91,7 +92,18 @@ func (s *Server) LoadBasedirsDB(dbPath, ownersPath string) error {

func (s *Server) getBasedirsGroupUsage(c *gin.Context) {
s.getBasedirs(c, func() (any, error) {
return s.basedirs.GroupUsage()
var results []*basedirs.Usage

for _, age := range summary.DirGUTAges {
result, err := s.basedirs.GroupUsage(age)
if err != nil {
return nil, err
}

results = append(results, result...)
}

return results, nil
})
}

Expand All @@ -116,7 +128,18 @@ func (s *Server) getBasedirs(c *gin.Context, cb func() (any, error)) {

func (s *Server) getBasedirsUserUsage(c *gin.Context) {
s.getBasedirs(c, func() (any, error) {
return s.basedirs.UserUsage()
var results []*basedirs.Usage

for _, age := range summary.DirGUTAges {
result, err := s.basedirs.UserUsage(age)
if err != nil {
return nil, err
}

results = append(results, result...)
}

return results, nil
})
}

Expand All @@ -140,7 +163,18 @@ func (s *Server) getBasedirsGroupSubdirs(c *gin.Context) {
}

s.getBasedirs(c, func() (any, error) {
return s.basedirs.GroupSubDirs(uint32(id), basedir)
var results []*basedirs.SubDir

for _, age := range summary.DirGUTAges {
result, err := s.basedirs.GroupSubDirs(uint32(id), basedir, age)
if err != nil {
return nil, err
}

results = append(results, result...)
}

return results, nil
})
}

Expand Down Expand Up @@ -177,7 +211,18 @@ func (s *Server) getBasedirsUserSubdirs(c *gin.Context) {
}

s.getBasedirs(c, func() (any, error) {
return s.basedirs.UserSubDirs(uint32(id), basedir)
var results []*basedirs.SubDir

for _, age := range summary.DirGUTAges {
result, err := s.basedirs.UserSubDirs(uint32(id), basedir, age)
if err != nil {
return nil, err
}

results = append(results, result...)
}

return results, nil
})
}

Expand Down
5 changes: 4 additions & 1 deletion server/static/wrstat/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ const groupNameToIDMap = new Map<string, number>(),
const daysAgo = asDaysAgo(mtime);

return daysAgo >= Math.max(filterMinDaysAgo, axisMinDaysAgo) && daysAgo <= Math.min(filterMaxDaysAgo, axisMaxDaysAgo);
}
},
Age: (rowAge: number) => {
return rowAge == age
},
}, baseFilter),
scatterFilter = Object.assign({
UsageSize: { min: axisMinSize, max: axisMaxSize },
Expand Down
4 changes: 2 additions & 2 deletions server/static/wrstat/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ auth.catch(() => createRoot(document.body).render(<StrictMode>

auth.then(username => Promise.all([
username,
RPC.getGroupUsageData().then(gud => {
RPC.getGroupUsageData(0).then(gud => {
for (const d of gud) {
d.percentSize = Math.round(10000 * d.UsageSize / d.QuotaSize) / 100;
d.percentInodes = Math.round(10000 * d.UsageInodes / d.QuotaInodes) / 100;
Expand All @@ -70,7 +70,7 @@ auth.then(username => Promise.all([

return gud;
}),
RPC.getUserUsageData(),
RPC.getUserUsageData(0),
RPC.getChildren({ path: "/" })
]))
.then(([username, groupUsage, userUsage, { areas, timestamp }]) => createRoot(document.body.firstElementChild!).render(<StrictMode>
Expand Down
8 changes: 4 additions & 4 deletions server/static/wrstat/src/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ const cache = new Map<string, string>(),

const RPC = {
"getChildren": (filter: ChildFilter) => getURL<Child>(treeURL, filter),
"getGroupUsageData": () => getURL<Usage[]>(groupUsageURL),
"getUserUsageData": () => getURL<Usage[]>(userUsageURL),
"getBasedirsGroupSubdirs": (id: number, basedir: string) => getURL<SubDir[]>(groupSubDirPathURL, { id, basedir }),
"getBasedirsUserSubdirs": (id: number, basedir: string) => getURL<SubDir[]>(userSubDirPathURL, { id, basedir }),
"getGroupUsageData": (age: number) => getURL<Usage[]>(groupUsageURL, { age }),
"getUserUsageData": (age: number) => getURL<Usage[]>(userUsageURL, { age }),
"getBasedirsGroupSubdirs": (id: number, basedir: string, age: number) => getURL<SubDir[]>(groupSubDirPathURL, { id, basedir, age }),
"getBasedirsUserSubdirs": (id: number, basedir: string, age: number) => getURL<SubDir[]>(userSubDirPathURL, { id, basedir, age }),
"getBasedirsHistory": (id: number, basedir: string) => getURL<History[]>(baseDirHistoryURL, { id, basedir })
};

Expand Down
1 change: 0 additions & 1 deletion server/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ func (s *Server) getTree(c *gin.Context) {
// children. If results don't belong to at least one of the allowedGIDs, they
// will be marked as NoAuth and won't include child info.
func (s *Server) diToTreeElement(di *dguta.DirInfo, filter *dguta.Filter, allowedGIDs map[uint32]bool, path string) *TreeElement {
s.Logger.Println("di in diToTreeElement: ", di)
if di == nil {
return &TreeElement{Path: path}
}
Expand Down

0 comments on commit ebac00a

Please sign in to comment.