Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
53b00d80
Commit
53b00d80
authored
Dec 16, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed GetOtherAccountsFor query
parent
705455d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
49 deletions
+4
-49
pkg/models/account.go
+2
-48
pkg/stores/sqlstore/sqlstore_accounts.go
+2
-1
No files found.
pkg/models/account.go
View file @
53b00d80
...
...
@@ -19,14 +19,6 @@ var (
ErrAccountNotFound
=
errors
.
New
(
"Account not found"
)
)
type
CollaboratorLink
struct
{
AccountId
int64
Role
string
Email
string
ModifiedOn
time
.
Time
CreatedOn
time
.
Time
}
type
OtherAccount
struct
{
Id
int64
Email
string
...
...
@@ -45,44 +37,6 @@ type Account struct {
Company
string
NextDashboardId
int
UsingAccountId
int64
Collaborators
[]
CollaboratorLink
`xorm:"-"`
Created
time
.
Time
`xorm:"CREATED"`
Updated
time
.
Time
`xorm:"UPDATED"`
}
func
(
account
*
Account
)
AddCollaborator
(
newCollaborator
*
Account
)
error
{
for
_
,
collaborator
:=
range
account
.
Collaborators
{
if
collaborator
.
AccountId
==
newCollaborator
.
Id
{
return
errors
.
New
(
"Collaborator already exists"
)
}
}
account
.
Collaborators
=
append
(
account
.
Collaborators
,
CollaboratorLink
{
AccountId
:
newCollaborator
.
Id
,
Email
:
newCollaborator
.
Email
,
Role
:
"admin"
,
CreatedOn
:
time
.
Now
(),
ModifiedOn
:
time
.
Now
(),
})
return
nil
}
func
(
account
*
Account
)
RemoveCollaborator
(
accountId
int64
)
{
list
:=
account
.
Collaborators
for
i
,
collaborator
:=
range
list
{
if
collaborator
.
AccountId
==
accountId
{
account
.
Collaborators
=
append
(
list
[
:
i
],
list
[
i
+
1
:
]
...
)
break
}
}
}
func
(
account
*
Account
)
HasCollaborator
(
accountId
int64
)
bool
{
for
_
,
collaborator
:=
range
account
.
Collaborators
{
if
collaborator
.
AccountId
==
accountId
{
return
true
}
}
return
false
Created
time
.
Time
`xorm:"CREATED"`
Updated
time
.
Time
`xorm:"UPDATED"`
}
pkg/stores/sqlstore/sqlstore_accounts.go
View file @
53b00d80
...
...
@@ -96,8 +96,9 @@ func AddCollaborator(collaborator *models.Collaborator) error {
func
GetOtherAccountsFor
(
accountId
int64
)
([]
*
models
.
OtherAccount
,
error
)
{
collaborators
:=
make
([]
*
models
.
OtherAccount
,
0
)
sess
:=
x
.
Table
(
"collaborator"
)
sess
.
Join
(
"INNER"
,
"account"
,
"
account.id=collaborator.account_I
d"
)
sess
.
Join
(
"INNER"
,
"account"
,
"
collaborator.for_account_id=account.i
d"
)
sess
.
Where
(
"account_id=?"
,
accountId
)
sess
.
Cols
(
"collaborator.id"
,
"collaborator.role"
,
"account.email"
)
err
:=
sess
.
Find
(
&
collaborators
)
return
collaborators
,
err
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment