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 EnableInstallation(identity []byte, installationID string) error
// DisableInstallation disable the installation. // DisableInstallation disable the installation.
DisableInstallation(identity []byte, installationID string) error 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) AddInstallations(identity []byte, timestamp int64, installations []*Installation, defaultEnabled bool) ([]*Installation, error)
// GetInstallations returns all the installations for a given identity // GetInstallations returns all the installations for a given identity
GetInstallations(identity []byte) ([]*Installation, error) GetInstallations(identity []byte) ([]*Installation, error)

View File

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