address feedback (#1503)

This commit is contained in:
Andrea Maria Piana 2019-07-01 16:28:13 +02:00 committed by GitHub
parent 3a1e244bdf
commit 46ae85d2e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 19 deletions

View file

@ -7,7 +7,7 @@ type Persistence interface {
EnableInstallation(identity []byte, installationID string) error
// DisableInstallation disable the installation.
DisableInstallation(identity []byte, installationID string) error
// AddInstallations adds the installations for a given identity, maintaining the enabled flag
// AddInstallations adds the installations for a given identity, maintaining the enabled flag and returns the newly inserted installations
AddInstallations(identity []byte, timestamp int64, installations []*Installation, defaultEnabled bool) ([]*Installation, error)
// GetInstallations returns all the installations for a given identity
GetInstallations(identity []byte) ([]*Installation, error)

View file

@ -76,29 +76,20 @@ func (s *SQLLitePersistence) GetInstallations(identity []byte) ([]*Installation,
}
for installationRows.Next() {
var (
installationID string
version uint32
enabled bool
timestamp int64
)
var installation Installation
err = installationRows.Scan(
&installationID,
&version,
&enabled,
&timestamp,
&installation.ID,
&installation.Version,
&installation.Enabled,
&installation.Timestamp,
)
if err != nil {
return nil, err
}
installationMap[installationID] = &Installation{
ID: installationID,
Version: version,
Enabled: enabled,
Timestamp: timestamp,
InstallationMetadata: &InstallationMetadata{},
}
// We initialized to empty in this case as we want to
// return metadata as well in this endpoint, but not in others
installation.InstallationMetadata = &InstallationMetadata{}
installationMap[installation.ID] = &installation
}
metadataStmt, err := s.db.Prepare(`SELECT installation_id, name, device_type, fcm_token FROM installation_metadata WHERE identity = ?`)