# Rake posts:rebake\_incremental (feature request)

**URL:** https://meta.discourse.org/t/rake-posts-rebake-incremental-feature-request/148806
**Category:** Feature
**Created:** [April 22, 2020, 4:34am UTC](https://meta.discourse.org/t/rake-posts-rebake-incremental-feature-request/148806 "2020-04-22T04:34:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [April 22, 2020, 4:34am UTC](https://meta.discourse.org/t/rake-posts-rebake-incremental-feature-request/148806/1 "2020-04-22T04:34:56Z")

</div>

Dear Discourse Developers,

RE: rake posts:rebake (future feature)

```plaintext
rake posts:rebake # Update each post with latest markdown
rake posts:rebake_match[pattern,type,delay] # Rebake all posts matching string/regex and optionally delay the loop

```

A. Would be great to have a rebake feature which lets the user rebake only if the topic id (or post id) is greater than some integer

```plaintext
rake posts:rebake_incremental['topic_id', 34567] #Rebakes if topic_id >= 34567
rake posts:rebake_incremental['post_id', 364123] #Rebakes if post_id >= 364123

```

Reasons:

(1) When rebaking, especially when working on migration tasks, developers may have already migrated topics/posts; but then later when they update the migration with new posts (for example in an active forum, when the migration is updated), there is no way (that I am aware of) to specify the starting point in the bake. Pattern matching is not designed for this (unless I am misunderstanding).

(2) When working on fine tuning text from old forums to discourse in migration tasks, for example, fine tuning special char in old forum to work with markdown in a coding forum, or fine tuning recursive bbcode in legacy forums, it is good to rebake, for example, the last 1000 posts (versus the entire DB).

B. Even More Flexible than A (Specify a comparative operator)

```plaintext
rake posts:rebake_incremental['topic_id', '>=',34567] #Rebakes if topic_id >= 34567
rake posts:rebake_incremental['post_id','<' , 364123] #Rebakes if post_id < 364123

```

Generic:

```plaintext
rake posts:rebake_incremental[target, operator, id]  

```

Where:

- target is either the topic\_id or the post\_id
- operator is a arithmetic comparison operator
- id is an integer, either topic\_id or post\_id

Note: Migration tasks often take a lot of interations to get it right; especially the text and encoding from posts in the original forum to discourse. There are many chars which can be used in a non-markdown-based forums which, when migrated to a markdown-processed forum, cause issues. Having more control over the rebaking process, as illustrated, would help.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [April 22, 2020, 6:00pm UTC](https://meta.discourse.org/t/rake-posts-rebake-incremental-feature-request/148806/2 "2020-04-22T18:00:10Z")

</div>

There’s also another rake task for rebaking:

```plaintext
rake posts:rebake_uncooked_posts

```

You could do all the stuff you requested and even more by running the following command in the rails console before executing the rake task from above.

```ruby
DB.exec(<<~SQL)
  UPDATE posts
  SET baked_version = NULL
  WHERE topic_id >= 34567
SQL

```

Simply adjust the condition to your special use case. In my book that’s a lot more flexible than a rake task.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [April 22, 2020, 9:28pm UTC](https://meta.discourse.org/t/rake-posts-rebake-incremental-feature-request/148806/3 "2020-04-22T21:28:36Z")

</div>

Perfect!!!

Thanks @gerhard !!

Totally agree 1000%

Love this rake task and method. It’s so great!

Thank you again!!

* * *

Note: One of the great things about this method suggested by @gerhard is that we can bake the last 1000 posts (for example) and if we like the cooked results, then go bake the rest of the 999,000 posts. This is truly a great gem of a feature.

Thank you again

* * *
