Archived
1
0
This commit is contained in:
Jeff Becker 2017-09-11 16:48:41 -04:00
parent 57b6b5050e
commit 723fa5aff5
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -872,7 +872,7 @@ func (self *PostgresDatabase) ArticleBanned(messageID string) (result bool) {
err := self.conn.QueryRow(self.stmt[ArticleBanned], messageID).Scan(&count) err := self.conn.QueryRow(self.stmt[ArticleBanned], messageID).Scan(&count)
if err == nil { if err == nil {
result = count > 0 result = count > 0
} else { } else if err != sql.ErrNoRows {
log.Println("error checking if article is banned", err) log.Println("error checking if article is banned", err)
} }
return return
@ -1307,9 +1307,9 @@ func (self *PostgresDatabase) GetLastBumpedThreadsPaginated(newsgroup string, th
func (self *PostgresDatabase) GroupHasPosts(group string) bool { func (self *PostgresDatabase) GroupHasPosts(group string) bool {
var count int64 var count int64
err := self.conn.QueryRow("SELECT COUNT(message_id) FROM ArticlePosts WHERE newsgroup = $1", group).Scan(&count) err := self.conn.QueryRow("SELECT 1 FROM ArticlePosts WHERE newsgroup = $1", group).Scan(&count)
if err != nil { if err == sql.ErrNoRows {
log.Println("error counting posts in group", group, err) err = nil
} }
return count > 0 return count > 0
} }
@ -1589,7 +1589,10 @@ func (self *PostgresDatabase) UnbanAddr(addr string) (err error) {
func (self *PostgresDatabase) CheckEncIPBanned(encaddr string) (banned bool, err error) { func (self *PostgresDatabase) CheckEncIPBanned(encaddr string) (banned bool, err error) {
var result int64 var result int64
err = self.conn.QueryRow(self.stmt[CheckEncIPBanned], encaddr).Scan(&result) err = self.conn.QueryRow(self.stmt[CheckEncIPBanned], encaddr).Scan(&result)
banned = result > 0 && err != sql.ErrNoRows if err == sql.ErrNoRows {
err = nil
}
banned = result > 0
return return
} }
@ -1638,7 +1641,7 @@ func (self *PostgresDatabase) UnMarkModPubkeyCanModGroup(pubkey, group string) (
func (self *PostgresDatabase) IsExpired(root_message_id string) bool { func (self *PostgresDatabase) IsExpired(root_message_id string) bool {
var count int var count int
err := self.conn.QueryRow(self.stmt[IsExpired], root_message_id).Scan(&count) err := self.conn.QueryRow(self.stmt[IsExpired], root_message_id).Scan(&count)
if err != nil { if err != nil && err != sql.ErrNoRows {
log.Println("error checking for expired article:", err) log.Println("error checking for expired article:", err)
} }
return count == 0 return count == 0