<commit_before>DROP VIEW IndexThreads;

CREATE OR REPLACE
 VIEW IndexThreads
 AS
 SELECT threads.*,
      tags.NSFW AS TagNSFW,
  (SELECT MAX(PostTime)
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID) AS LatestPostTime,
  (SELECT PostID
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID
   ORDER BY PostID LIMIT 1) AS PostID,
  (SELECT MAX(PostTime)
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID
     AND Bump = true) AS LatestBump,
  tags.TagName as Tag,
  tags.UserStatusID,
  (SELECT COUNT(1)
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID) - 1 AS PostCount
 FROM threads
 LEFT JOIN posts ON (threads.ThreadID = posts.ThreadID)
 LEFT JOIN tags ON tags.TagID = threads.TagID
 GROUP BY threads.ThreadID,
          tags.NSFW,
          tags.TagName,
          tags.UserStatusID
 ORDER BY Stickied DESC, LatestBump;<commit_msg>fixed sort order of threads<commit_after>DROP VIEW IndexThreads;

CREATE OR REPLACE
 VIEW IndexThreads
 AS
 SELECT threads.*,
      tags.NSFW AS TagNSFW,
  (SELECT MAX(PostTime)
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID) AS LatestPostTime,
  (SELECT PostID
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID
   ORDER BY PostID LIMIT 1) AS PostID,
  (SELECT MAX(PostTime)
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID
     AND Bump = true) AS LatestBump,
  tags.TagName as Tag,
  tags.UserStatusID,
  (SELECT COUNT(1)
   FROM posts
   WHERE threads.ThreadID = posts.ThreadID) - 1 AS PostCount
 FROM threads
 LEFT JOIN posts ON (threads.ThreadID = posts.ThreadID)
 LEFT JOIN tags ON tags.TagID = threads.TagID
 GROUP BY threads.ThreadID,
          tags.NSFW,
          tags.TagName,
          tags.UserStatusID
 ORDER BY Stickied DESC, LatestBump DESC;
{'fraction_non_alphanumeric': 0.06991404011461318, 'fraction_numerical': 0.0034383954154727794, 'mean_word_length': 3.1971153846153846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7360911', 'n_tokens_mistral': 583, 'n_tokens_neox': 555, 'n_words': 180}