(coll *CollectionObj, includeFuture bool)
| 1897 | } |
| 1898 | |
| 1899 | func (db *datastore) GetPinnedPosts(coll *CollectionObj, includeFuture bool) (*[]PublicPost, error) { |
| 1900 | // FIXME: sqlite-backed instances don't include ellipsis on truncated titles |
| 1901 | timeCondition := "" |
| 1902 | if !includeFuture { |
| 1903 | timeCondition = "AND created <= " + db.now() |
| 1904 | } |
| 1905 | rows, err := db.Query("SELECT id, slug, title, "+db.clip("content", 80)+", pinned_position FROM posts WHERE collection_id = ? AND pinned_position IS NOT NULL "+timeCondition+" ORDER BY pinned_position ASC", coll.ID) |
| 1906 | if err != nil { |
| 1907 | log.Error("Failed selecting pinned posts: %v", err) |
| 1908 | return nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't retrieve pinned posts."} |
| 1909 | } |
| 1910 | defer rows.Close() |
| 1911 | |
| 1912 | posts := []PublicPost{} |
| 1913 | for rows.Next() { |
| 1914 | p := &Post{} |
| 1915 | err = rows.Scan(&p.ID, &p.Slug, &p.Title, &p.Content, &p.PinnedPosition) |
| 1916 | if err != nil { |
| 1917 | log.Error("Failed scanning row: %v", err) |
| 1918 | break |
| 1919 | } |
| 1920 | p.extractData() |
| 1921 | p.augmentContent(&coll.Collection) |
| 1922 | |
| 1923 | pp := p.processPost() |
| 1924 | pp.Collection = coll |
| 1925 | posts = append(posts, pp) |
| 1926 | } |
| 1927 | return &posts, nil |
| 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) |
nothing calls this directly
no test coverage detected