[Gekidou] Allow multiple posts in thread and posts in channel for a specific root or channel (#5594)

* Allow multiple posts in thread and posts in channel for a specific root or channel

* Apply suggestions from code review

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
This commit is contained in:
Elias Nahum
2021-08-04 15:43:25 -04:00
committed by GitHub
parent 733b10377b
commit 7c5b3a1574
15 changed files with 34 additions and 12 deletions

View File

@@ -75,7 +75,7 @@ const PostsInChannelHandler = (superclass: any) => class extends superclass {
// Find the records in the PostsInChannel table that have a matching channel_id
const chunks = (await this.database.get(POSTS_IN_CHANNEL).query(
Q.where('id', channelId),
Q.where('channel_id', channelId),
Q.experimentalSortBy('latest', Q.desc),
).fetch()) as PostsInChannelModel[];

View File

@@ -32,13 +32,13 @@ const PostsInThreadHandler = (superclass: any) => class extends superclass {
const chunks = (await retrieveRecords({
database: this.database,
tableName: POSTS_IN_THREAD,
condition: Q.where('id', rootId),
condition: Q.where('root_id', rootId),
})) as PostsInThreadModel[];
if (chunks.length) {
const chunk = chunks[0];
const newValue = {
id: rootId,
root_id: rootId,
earliest: Math.min(chunk.earliest, firstPost.create_at),
latest: Math.max(chunk.latest, lastPost.create_at),
};
@@ -50,7 +50,7 @@ const PostsInThreadHandler = (superclass: any) => class extends superclass {
} else {
// create chunk
create.push({
id: rootId,
root_id: rootId,
earliest: firstPost.create_at,
latest: lastPost.create_at,
});