-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* GET endpoint for retrieving the first seven matches among all users in Okra, used for autocompleting when adding a user * GET endpoint for retrieving all members in an Org
- Loading branch information
dmonay
committed
Jan 16, 2015
1 parent
bec6c89
commit 6ddfbaa
Showing
6 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package handlers | ||
|
||
import ( | ||
"github.com/dmonay/okra/common" | ||
"github.com/gin-gonic/gin" | ||
"gopkg.in/mgo.v2/bson" | ||
) | ||
|
||
func (dw *DoWorkResource) GetMembers(c *gin.Context) { | ||
org := c.Params.ByName("org") | ||
|
||
var result common.MembersInOrg | ||
err := dw.mongo.C(org).Find(bson.M{"name": "membersArray"}).One(&result) | ||
if err != nil { | ||
CheckErr(err, "Failed to retrieve members in "+org+" org", c) | ||
return | ||
} | ||
|
||
c.JSON(200, SuccessMsg{result.Members}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package handlers | ||
|
||
import ( | ||
"github.com/dmonay/okra/common" | ||
"github.com/gin-gonic/gin" | ||
"gopkg.in/mgo.v2/bson" | ||
) | ||
|
||
func (dw *DoWorkResource) GetAllUsers(c *gin.Context) { | ||
user := c.Params.ByName("user") | ||
|
||
var results []common.UsersObj | ||
err := dw.mongo.C("Users").Find(bson.M{"username": bson.M{"$regex": bson.RegEx{Pattern: user, Options: "i"}}}).All(&results) | ||
if err != nil { | ||
CheckErr(err, "Failed to get all users", c) | ||
return | ||
} | ||
var result []string | ||
count := 0 | ||
for _, value := range results { | ||
count++ | ||
result = append(result, value.Username) | ||
if count == 7 { | ||
break | ||
} | ||
} | ||
|
||
c.JSON(200, SuccessMsg{result}) | ||
} |