remove fully
This commit is contained in:
parent
28e8e95207
commit
a9f8bf2f8c
@ -49,11 +49,10 @@ func (self PostEntry) Count() int64 {
|
||||
|
||||
type PostEntryList []PostEntry
|
||||
|
||||
|
||||
// stats about newsgroup postings
|
||||
type NewsgroupStats struct {
|
||||
PPD int64
|
||||
Name string
|
||||
PPD int64
|
||||
Name string
|
||||
}
|
||||
|
||||
type PostingStatsEntry struct {
|
||||
@ -69,8 +68,6 @@ type NewsgroupListEntry [3]string
|
||||
|
||||
type NewsgroupList []NewsgroupListEntry
|
||||
|
||||
|
||||
|
||||
type Database interface {
|
||||
Close()
|
||||
CreateTables()
|
||||
@ -247,6 +244,9 @@ type Database interface {
|
||||
// delete an article from the database
|
||||
DeleteArticle(msg_id string) error
|
||||
|
||||
// remove an article from the database
|
||||
RemoveArticle(msg_id string) error
|
||||
|
||||
// detele the existance of a thread from the threads table, does NOT remove replies
|
||||
DeleteThread(root_msg_id string) error
|
||||
|
||||
|
@ -442,10 +442,11 @@ func (mod *modEngine) Do(ev ModEvent) {
|
||||
// TODP: implement
|
||||
} else if action == ModRemove {
|
||||
if ValidMessageID(target) {
|
||||
err := mod.database.DeleteArticle(target)
|
||||
if err == nil {
|
||||
err = mod.store.Remove(target)
|
||||
err := mod.database.RemoveArticle(target)
|
||||
if err != nil {
|
||||
log.Println("failed to forget", target, "because:", err)
|
||||
}
|
||||
err = mod.store.Remove(target)
|
||||
if err == nil {
|
||||
log.Println("removed", target)
|
||||
} else {
|
||||
|
@ -153,10 +153,11 @@ const GetYearlyPostHistory = "GetYearlyPostHistory"
|
||||
const GetNewsgroupList = "GetNewsgroupList"
|
||||
const CountUkko = "CountUkko"
|
||||
const GetNewsgroupStats = "GetNewsgroupStats"
|
||||
const RemoveArticle = "RemoveArticle"
|
||||
|
||||
func (self *PostgresDatabase) prepareStatements() {
|
||||
self.stmt = map[string]string{
|
||||
GetNewsgroupStats: "SELECT COUNT(message_id), newsgroup FROM articleposts WHERE time_posted > (EXTRACT(epoch FROM NOW()) - (24*3600)) GROUP BY newsgroup",
|
||||
GetNewsgroupStats: "SELECT COUNT(message_id), newsgroup FROM articleposts WHERE time_posted > (EXTRACT(epoch FROM NOW()) - (24*3600)) GROUP BY newsgroup",
|
||||
NewsgroupBanned: "SELECT 1 FROM BannedGroups WHERE newsgroup = $1",
|
||||
ArticleBanned: "SELECT 1 FROM BannedArticles WHERE message_id = $1",
|
||||
GetAllNewsgroups: "SELECT name FROM Newsgroups WHERE name NOT IN ( SELECT newsgroup FROM BannedGroups )",
|
||||
@ -226,6 +227,7 @@ func (self *PostgresDatabase) prepareStatements() {
|
||||
GetCitesByPostHashLike: "SELECT message_id, message_ref_id FROM Articles WHERE message_id_hash LIKE $1",
|
||||
GetYearlyPostHistory: "WITH times(endtime, begintime) AS ( SELECT CAST(EXTRACT(epoch from i) AS BIGINT) AS endtime, CAST(EXTRACT(epoch from i - interval '1 month') AS BIGINT) AS begintime FROM generate_series(now() - interval '10 year', now(), '1 month'::interval) i ) SELECT begintime, endtime, ( SELECT count(*) FROM ArticlePosts WHERE time_posted > begintime AND time_posted < endtime) FROM times",
|
||||
CountUkko: "SELECT COUNT(message_id) FROM ArticlePosts WHERE newsgroup != 'ctl' AND ref_id = '' OR ref_id = message_id",
|
||||
RemoveArticle: "DELETE FROM Articles WHERE message_id = $1",
|
||||
}
|
||||
|
||||
}
|
||||
@ -1245,6 +1247,14 @@ func (self *PostgresDatabase) DeleteArticle(msgid string) (err error) {
|
||||
*/
|
||||
_, err = self.conn.Exec(self.stmt[DeleteArticleV8], msgid)
|
||||
return
|
||||
|
||||
}
|
||||
func (self *PostgresDatabase) RemoveArticle(msgid string) (err error) {
|
||||
_, err = self.conn.Exec(self.stmt[DeleteArticleV8], msgid)
|
||||
if err == nil {
|
||||
_, err = self.conn.Exec(self.stmt[RemoveArticle], msgid)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (self *PostgresDatabase) GetThreadReplyPostModels(prefix, rootpost string, start, limit int) (repls []PostModel) {
|
||||
@ -2053,7 +2063,7 @@ func (self *PostgresDatabase) GetUkkoPageCount(perpage int) (count int64, err er
|
||||
return
|
||||
}
|
||||
|
||||
func (self *PostgresDatabase) GetNewsgroupStats() (stats []NewsgroupStats, err error) {
|
||||
func (self *PostgresDatabase) GetNewsgroupStats() (stats []NewsgroupStats, err error) {
|
||||
var rows *sql.Rows
|
||||
rows, err = self.conn.Query(self.stmt[GetNewsgroupStats])
|
||||
if err == nil {
|
||||
@ -2067,7 +2077,6 @@ func (self *PostgresDatabase) GetNewsgroupStats() (stats []NewsgroupStats, err e
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
func (self *PostgresDatabase) FindHeaders(group, headername string, lo, hi int64) (hdr ArticleHeaders, err error) {
|
||||
hdr = make(ArticleHeaders)
|
||||
q := "SELECT header_value FROM nntpheaders WHERE header_name = $1 AND header_article_message_id IN ( SELECT message_id FROM articleposts WHERE newsgroup = $2 )"
|
||||
|
Reference in New Issue
Block a user