(u *User, hostName string)
| 1928 | } |
| 1929 | |
| 1930 | func (db *datastore) GetCollections(u *User, hostName string) (*[]Collection, error) { |
| 1931 | rows, err := db.Query("SELECT id, alias, title, description, privacy, view_count FROM collections WHERE owner_id = ? ORDER BY id ASC", u.ID) |
| 1932 | if err != nil { |
| 1933 | log.Error("Failed selecting from collections: %v", err) |
| 1934 | return nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't retrieve user collections."} |
| 1935 | } |
| 1936 | defer rows.Close() |
| 1937 | |
| 1938 | colls := []Collection{} |
| 1939 | for rows.Next() { |
| 1940 | c := Collection{} |
| 1941 | err = rows.Scan(&c.ID, &c.Alias, &c.Title, &c.Description, &c.Visibility, &c.Views) |
| 1942 | if err != nil { |
| 1943 | log.Error("Failed scanning row: %v", err) |
| 1944 | break |
| 1945 | } |
| 1946 | c.hostName = hostName |
| 1947 | c.URL = c.CanonicalURL() |
| 1948 | c.Public = c.IsPublic() |
| 1949 | |
| 1950 | /* |
| 1951 | // NOTE: future functionality |
| 1952 | if visibility != nil { // TODO: && visibility == CollPublic { |
| 1953 | // Add Monetization info when retrieving all public collections |
| 1954 | c.Monetization = db.GetCollectionAttribute(c.ID, "monetization_pointer") |
| 1955 | } |
| 1956 | */ |
| 1957 | |
| 1958 | colls = append(colls, c) |
| 1959 | } |
| 1960 | err = rows.Err() |
| 1961 | if err != nil { |
| 1962 | log.Error("Error after Next() on rows: %v", err) |
| 1963 | } |
| 1964 | |
| 1965 | return &colls, nil |
| 1966 | } |
| 1967 | |
| 1968 | func (db *datastore) GetPublishableCollections(u *User, hostName string) (*[]Collection, error) { |
| 1969 | c, err := db.GetCollections(u, hostName) |
no test coverage detected