mirror of
https://github.com/vbatts/imgsrv.git
synced 2025-07-29 02:10:29 +00:00
now we have an /ext/ listing
This commit is contained in:
parent
5eab319c6c
commit
e3548407b2
2 changed files with 77 additions and 5 deletions
|
@ -62,6 +62,39 @@ func (u Util) HasFileByKeyword(keyword string) (exists bool, err error) {
|
|||
return exists, nil
|
||||
}
|
||||
|
||||
/*
|
||||
get a list of file extensions and their frequency count
|
||||
*/
|
||||
func (u Util) GetExtensions() (kp []types.IdCount, err error) {
|
||||
job := &mgo.MapReduce{
|
||||
Map: `
|
||||
function() {
|
||||
if (!this.filename) {
|
||||
return;
|
||||
}
|
||||
|
||||
s = this.filename.split(".")
|
||||
ext = s[s.length - 1] // get the last segment of the split
|
||||
emit(ext,1);
|
||||
}
|
||||
`,
|
||||
Reduce: `
|
||||
function(previous, current) {
|
||||
var count = 0;
|
||||
|
||||
for (index in current) {
|
||||
count += current[index];
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
`,
|
||||
}
|
||||
if _, err := u.Gfs.Find(nil).MapReduce(job, &kp); err != nil {
|
||||
return kp, err
|
||||
}
|
||||
return kp, nil
|
||||
}
|
||||
/*
|
||||
get a list of keywords and their frequency count
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue