aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-01-30 18:43:29 -0800
committerAdam Mathes <adam@trenchant.org>2017-01-30 18:43:29 -0800
commit09a859501fc1fb1f4f781cfdd448f359b7ef4983 (patch)
tree08d5e0e942b88d47e5799c406de640f49c305756 /models
parent030cfcce60658ede58a31b36704a3a417c346a4c (diff)
downloadneko-09a859501fc1fb1f4f781cfdd448f359b7ef4983.tar.gz
neko-09a859501fc1fb1f4f781cfdd448f359b7ef4983.tar.bz2
neko-09a859501fc1fb1f4f781cfdd448f359b7ef4983.zip
add back in starred functionality, fix login page
Diffstat (limited to 'models')
-rw-r--r--models/item/item.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/models/item/item.go b/models/item/item.go
index 51166c4..3cf8a19 100644
--- a/models/item/item.go
+++ b/models/item/item.go
@@ -14,6 +14,7 @@ type Item struct {
Url string `json:"url"`
Description string `json:"description"`
ReadState bool `json:"read"`
+ Starred bool `json:"starred"`
FeedId int64
PublishDate string `json:"publish_date"`
FeedTitle string `json:"feed_title"`
@@ -42,8 +43,8 @@ func (i *Item) Create() error {
func (i *Item) Save() {
_, err := models.DB.Exec(`UPDATE item
- SET read_state=?
- WHERE id=?`, i.ReadState, i.Id)
+ SET read_state=?, starred=?
+ WHERE id=?`, i.ReadState, i.Starred, i.Id)
if err != nil {
log.Println(err)
}
@@ -58,12 +59,12 @@ func (i *Item) FullSave() {
}
}
-func Filter(max_id int64, feed_id int64, unread_only bool) ([]*Item, error) {
+func Filter(max_id int64, feed_id int64, unread_only bool, starred_only bool) ([]*Item, error) {
var args []interface{}
query := `SELECT item.id, item.title, item.url, item.description,
- item.read_state, item.publish_date,
+ item.read_state, item.starred, item.publish_date,
feed.url, feed.title
FROM item,feed
WHERE item.feed_id=feed.id `
@@ -82,6 +83,11 @@ func Filter(max_id int64, feed_id int64, unread_only bool) ([]*Item, error) {
query = query + " AND item.read_state=0 "
}
+ if starred_only {
+ query = query + " AND item.starred=1 "
+ }
+
+
query = query + "ORDER BY item.id DESC LIMIT 15"
// log.Println(query)
// log.Println(args...)
@@ -102,7 +108,7 @@ func Filter(max_id int64, feed_id int64, unread_only bool) ([]*Item, error) {
items := make([]*Item, 0)
for rows.Next() {
i := new(Item)
- err := rows.Scan(&i.Id, &i.Title, &i.Url, &i.Description, &i.ReadState, &i.PublishDate, &i.FeedUrl, &i.FeedTitle)
+ err := rows.Scan(&i.Id, &i.Title, &i.Url, &i.Description, &i.ReadState, &i.Starred, &i.PublishDate, &i.FeedUrl, &i.FeedTitle)
if err != nil {
log.Println(err)
return nil, err