forked from rapidpro/mailroom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load user assets with their teams and record reply daily counts for o…
…rg, user and team
- Loading branch information
1 parent
3a362e6
commit cb5465e
Showing
11 changed files
with
127 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package models | ||
|
||
import ( | ||
"database/sql/driver" | ||
|
||
"github.com/nyaruka/null" | ||
) | ||
|
||
const ( | ||
// NilTeamID is the id 0 considered as nil user id | ||
NilTeamID = TeamID(0) | ||
) | ||
|
||
// TeamID is our type for team ids, which can be null | ||
type TeamID null.Int | ||
|
||
type TeamUUID string | ||
|
||
type Team struct { | ||
ID TeamID `json:"id"` | ||
UUID TeamUUID `json:"uuid"` | ||
Name string `json:"name"` | ||
} | ||
|
||
// MarshalJSON marshals into JSON. 0 values will become null | ||
func (i TeamID) MarshalJSON() ([]byte, error) { | ||
return null.Int(i).MarshalJSON() | ||
} | ||
|
||
// UnmarshalJSON unmarshals from JSON. null values become 0 | ||
func (i *TeamID) UnmarshalJSON(b []byte) error { | ||
return null.UnmarshalInt(b, (*null.Int)(i)) | ||
} | ||
|
||
// Value returns the db value, null is returned for 0 | ||
func (i TeamID) Value() (driver.Value, error) { | ||
return null.Int(i).Value() | ||
} | ||
|
||
// Scan scans from the db value. null values become 0 | ||
func (i *TeamID) Scan(value interface{}) error { | ||
return null.ScanInt(value, (*null.Int)(i)) | ||
} |
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
Binary file not shown.
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