Archiving Posts

Looking to ape the archiving by too old+no reply but is there a way to hack the search query string to exclude certain boards - my results are pulling all content from archived boards!

Message 11 of 23
Highlighted
Community Management
Customer Service

Our developer build a component that allows us to archive topics that have not seen activity in a specified date range, board by board.

@fuenteso. Can you help Mike out a bit?

Learning from others and helping where I can!
Community Passionista!
Message 12 of 23

Anything that you can share would be appreciated, @fuenteso!  The archive tool that you built is really interesting and in my opinion, really crucial to Communities. While we wait to see if Lithium will make a standard Community solution, any way to make this process easier is going to be helpful!


Samantha O'Connor
Community Manager
Message 13 of 23
That would be great. Manual process is killing me! Still Spotify is getting a good workout
Message 14 of 23

Hi,

 

Sure. It's a two part tool; we have a custom component on each of the category/board pages visible only to admins/mods where they can select a time range (two simple form date fields), the board we want to 'clean' and the destination board (or archive board). Additionally we added a few options in the form of checkboxes to archived only solved threads, or archive them by original post date instead of conversation.last_post_date.

 

This component then calls an endpoint and send all this information as parameters. This endpoint uses an API v2 call to pull the threads

 

SELECT count(*) FROM messages WHERE conversation.last_post_time <= ${endDate} AND conversation.last_post_time > ${startDate} AND depth = 0 AND board.id='${board}'

Then loop through the list and move each thread individually. We add a couple of tags to preserve the original board id and mark the thread as Archived.

<#assign apiResults = rest('/messages/id/${post.id}/tagging/tags/add?tag.add=Archived') />
<#assign apiResults = rest('/messages/id/${post.id}/tagging/tags/add?tag.add=source-board-id:${post.board.id}') />
<#assign apiResults = rest('/messages/id/${post.id}/move/board/id/${moveTo}?move_message.include_replies=true&move_message.ignore_notification=true') />

It might be a good idea to pull the threads in batches. For example we're processing 100 threads at a time (getting the total number of threads in scope, dividing it by 100 and then use that "page" number with OFFSET to )

<#assign resultPages = (postCount/queryLimit)?int+1 /> 
<#list 0..resultPages as page>
<#assign postsToArchive = rest(apiVersion, "/search?q=" + "SELECT id, board, conversation, view_href, metrics, post_time FROM messages WHERE conversation.last_post_time <= ${endDate} AND conversation.last_post_time > ${startDate} AND depth = 0 AND board.id='${board}'${notSolvedQuery} ORDER BY conversation.last_post_time DESC LIMIT ${queryLimit} OFFSET ${page*queryLimit}"?url).data.items />
...
<#/list>

I also added an extra step to make sure the post's conversation.last_post_time fell into the specified date range. I think there was a bug on the API call that was returning threads that didn't meet the contraints.

 

Finally, the endpoint returns a JSON with useful information, like the IDs of all the threads that were moved. You can choose to create a report with this information or just ignore it.

 

Hope that helps, let me know if you have any questions.

 

 

Tags (1)
Message 15 of 23
This looks awesome, I've not got this deep into the code before, so please excuse my ignorant questions.
First block is an endpoint?
Next 2 blocks are new components I create and then drop into pages?
Message 16 of 23

Hi @VF_MikeHales

 

Not exactly, that's like a general description of how it works.

 

I can share with you the actual code but since it was built specifically for our community it needs a certain degree of personalization for it to work on a different environment (archive board structure, board names, roles, styling, etc). 

Message 17 of 23
That would be awesome and if you could mark the site-specific parts that would be great. Have managed to batch process my entire community down to one year but anything that can help automate in the future would be super cool.
Thanks again
Message 18 of 23

@fuenteso, if the offer is an open one, would you mind sharing this with me, too?  I'm happy to send along my email address if that is easiest for you. 

 

 

Thanks! 


Samantha O'Connor
Community Manager
Message 19 of 23
Community Management
Customer Service
I think @fuenteso deserves an extra call out this month ;-)
Learning from others and helping where I can!
Community Passionista!
Message 20 of 23