Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Concept of a Team #28

Open
bradley-holt opened this issue Jul 29, 2016 · 5 comments
Open

Add a Concept of a Team #28

bradley-holt opened this issue Jul 29, 2016 · 5 comments

Comments

@bradley-holt
Copy link

Create a concept of a "team" (team field) to which each user will be attached. Each user needs to only belong to one team. Users may not add or remove themselves from teams. Only system administrators can edit who is in a team. Perhaps for now this is by way of directly editing the database?

@glynnbird
Copy link
Contributor

There already is a concept of a 'team' in Advocated. We have a 'teams' database which contains documents like this:

{
  "_id": "T08LVEX7Y",
  "_rev": "1-9de36270d0d24adf6c2f4ecec17ff324",
  "type": "team",
  "name": "IBM Analytics",
  "slack": {
    "token": "abc123abc123abc123",
    "webhook": "https://hooks.slack.com/services/XXX/YYYY/ZZZZZ"
  }
}

We currently have two teams. IBM Analytics and Bluemix, corresponding to the two Slack accounts that use this service. We can use this concept of 'teams' to divide totals between users who belong to these groups.

But I suspect you are looking for a different grouping of people. For instance, even in our own Slack group we may want to create a grouping of users that reflects the CDS Developer Advocates, for instance.

To avoid clashes with nomenclature here, if we call this new grouping of users 'group', for example, then we could make a sure that all the CDS Dev Advocates have a group: 'cds-dev-advocates' field in their user record. This would allow us to report on totals for members of that group.

What do you think @bradley-holt ?

@bradley-holt
Copy link
Author

@glynnbird Works for me! I agree that "group" would be better to avoid confusion with the existing concept of "team." As you mentioned, we will want to have multiple groups per Slack team. We may even want to have people in different Slack teams be in the same group (unlikely, but possible). So, these should be independent concepts.

@glynnbird
Copy link
Contributor

cool! Thanks for the clarification

@glynnbird
Copy link
Contributor

The v2 of Advocated does have teams (in terms of Slack domains) but not groups as discussed above. It's actually really hard to do. First of all the user data isn't replicated to the mobile device anymore: it used to be in the same database as the events/blogs etc but now it's in the "envoyusers" database. So although I could add a group:"CDS Advocates" into all of our advocate's records. It wouldn't have any effect for users who are already logged into Advocated.

It might be best to tackle groups at "report time". If we know that X users represent a group, we can get totals of, say, expenditure for "where userid in X". This isn't a query that Cloudant does well: Cloudant Query doesn't have aggregation and a mapreduce view doesn't help.

We can, however, create custom MapReduce functions like this:

  map = function(doc) {
    var users= ['bradley','glynn','matt'];
    if (user.indexOf(doc.userid) >=-1 ) {
        // emit stuff
    }    

 } 

It's a bit of a hack but it gives us reports and keeps the logic "server side" :)

@bradley-holt
Copy link
Author

OK. Let's discuss the specifics of this in #29 and in #30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants