note expiration added
This commit is contained in:
@@ -9,8 +9,11 @@
|
|||||||
- **Statistics**: a rudimentary statistics available (date of publishing & view counter).
|
- **Statistics**: a rudimentary statistics available (date of publishing & view counter).
|
||||||
- **Export**: the original markdown content can be displayed in plain text format.
|
- **Export**: the original markdown content can be displayed in plain text format.
|
||||||
- **API**: Integrate the publishing functionality into your editor using the official [NoteHub API](/api).
|
- **API**: Integrate the publishing functionality into your editor using the official [NoteHub API](/api).
|
||||||
|
- **Expiration**: All notes with less than 30 views in 30 days from publishing will expire.
|
||||||
|
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
- March 2014: all notes with __less than 30 views in 30 days from publishing__ will expire now
|
||||||
- February 2014: a simple JS-client for API testing [added](/api-test.html).
|
- February 2014: a simple JS-client for API testing [added](/api-test.html).
|
||||||
- January 2014:
|
- January 2014:
|
||||||
- Mobile friendly styling added.
|
- Mobile friendly styling added.
|
||||||
|
|||||||
@@ -131,3 +131,16 @@
|
|||||||
; we save all short urls of a note for removal later
|
; we save all short urls of a note for removal later
|
||||||
(redis :sadd (str noteID :urls) url)
|
(redis :sadd (str noteID :urls) url)
|
||||||
url))))
|
url))))
|
||||||
|
|
||||||
|
(defn gc [password]
|
||||||
|
(when (= password (get-setting :admin-pw))
|
||||||
|
(let [N 30
|
||||||
|
timestamp (- (get-current-date) (* N 24 60 60 1000))
|
||||||
|
all-notes (map first (partition 2 (redis :hgetall :note)))
|
||||||
|
old-notes (filter #(< (Long/parseLong (redis :hget :published %)) timestamp) all-notes)
|
||||||
|
unpopular-notes (filter #(< (try (Long/parseLong (redis :hget :views %))
|
||||||
|
(catch Exception a 0)) N) old-notes)]
|
||||||
|
(println "timestamp:" (str (java.util.Date. timestamp)))
|
||||||
|
(println (count unpopular-notes) "deleted")
|
||||||
|
(doseq [note-id unpopular-notes]
|
||||||
|
(delete-note note-id)))))
|
||||||
|
|||||||
Reference in New Issue
Block a user