add files count column in channel info table and db migration
This commit is contained in:
parent
ba523fab15
commit
763df58ef8
12 changed files with 35 additions and 3 deletions
|
|
@ -429,6 +429,7 @@ export async function fetchChannelStats(serverUrl: string, channelId: string, fe
|
|||
id: channelId,
|
||||
member_count: stats.member_count,
|
||||
pinned_post_count: stats.pinnedpost_count,
|
||||
files_count: stats.files_count,
|
||||
}];
|
||||
await operator.handleChannelInfo({channelInfos, prepareRecordsOnly: false});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,22 @@
|
|||
// NOTE : To implement migration, please follow this document
|
||||
// https://nozbe.github.io/WatermelonDB/Advanced/Migrations.html
|
||||
|
||||
import {schemaMigrations} from '@nozbe/watermelondb/Schema/migrations';
|
||||
import {addColumns, schemaMigrations} from '@nozbe/watermelondb/Schema/migrations';
|
||||
|
||||
export default schemaMigrations({migrations: []});
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {CHANNEL_INFO} = MM_TABLES.SERVER;
|
||||
|
||||
export default schemaMigrations({migrations: [
|
||||
{
|
||||
toVersion: 2,
|
||||
steps: [
|
||||
addColumns({
|
||||
table: CHANNEL_INFO,
|
||||
columns: [
|
||||
{name: 'files_count', type: 'number'},
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
]});
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ export default class ChannelInfoModel extends Model implements ChannelInfoInterf
|
|||
/** pinned_post_count : The number of post pinned in this channel */
|
||||
@field('pinned_post_count') pinnedPostCount!: number;
|
||||
|
||||
/** pinned_post_count : The number of files in this channel */
|
||||
@field('files_count') filesCount!: number;
|
||||
|
||||
/** purpose: The intention behind this channel */
|
||||
@field('purpose') purpose!: string;
|
||||
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ const ChannelHandler = <TBase extends Constructor<ServerDataOperatorBase>>(super
|
|||
ci.member_count !== e.memberCount ||
|
||||
ci.header !== e.header ||
|
||||
ci.pinned_post_count !== e.pinnedPostCount ||
|
||||
ci.files_count !== e.filesCount ||
|
||||
ci.purpose !== e.purpose
|
||||
) {
|
||||
res.push(ci);
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ describe('*** CHANNEL Prepare Records Test ***', () => {
|
|||
header: 'channel info header',
|
||||
member_count: 10,
|
||||
pinned_post_count: 3,
|
||||
files_count: 0,
|
||||
purpose: 'sample channel ',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ export const transformChannelInfoRecord = ({action, database, value}: Transforme
|
|||
channelInfo.header = raw.header ?? channelInfo.header ?? '';
|
||||
channelInfo.memberCount = raw.member_count ?? channelInfo.memberCount ?? 0;
|
||||
channelInfo.pinnedPostCount = raw.pinned_post_count ?? channelInfo.pinnedPostCount ?? 0;
|
||||
channelInfo.filesCount = raw.files_count ?? channelInfo.filesCount ?? 0;
|
||||
channelInfo.purpose = raw.purpose ?? channelInfo.purpose ?? '';
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import {
|
|||
} from './table_schemas';
|
||||
|
||||
export const serverSchema: AppSchema = appSchema({
|
||||
version: 1,
|
||||
version: 2,
|
||||
tables: [
|
||||
CategorySchema,
|
||||
CategoryChannelSchema,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export default tableSchema({
|
|||
{name: 'header', type: 'string'},
|
||||
{name: 'member_count', type: 'number'},
|
||||
{name: 'pinned_post_count', type: 'number'},
|
||||
{name: 'files_count', type: 'number'},
|
||||
{name: 'purpose', type: 'string'},
|
||||
],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export function prepareMissingChannelsForAllTeams(operator: ServerDataOperator,
|
|||
guest_count: 0,
|
||||
member_count: 0,
|
||||
pinned_post_count: 0,
|
||||
files_count: 0,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -95,12 +96,14 @@ export const prepareMyChannelsForTeam = async (operator: ServerDataOperator, tea
|
|||
let member_count = 0;
|
||||
let guest_count = 0;
|
||||
let pinned_post_count = 0;
|
||||
let files_count = 0;
|
||||
if (storedChannel) {
|
||||
storedInfo = allChannelsInfoForTeam[c.id];
|
||||
if (storedInfo) {
|
||||
member_count = storedInfo.memberCount;
|
||||
guest_count = storedInfo.guestCount;
|
||||
pinned_post_count = storedInfo.pinnedPostCount;
|
||||
files_count = storedInfo.filesCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +114,7 @@ export const prepareMyChannelsForTeam = async (operator: ServerDataOperator, tea
|
|||
guest_count,
|
||||
member_count,
|
||||
pinned_post_count,
|
||||
files_count,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
1
types/api/channels.d.ts
vendored
1
types/api/channels.d.ts
vendored
|
|
@ -6,6 +6,7 @@ type ChannelStats = {
|
|||
guest_count: number;
|
||||
member_count: number;
|
||||
pinnedpost_count: number;
|
||||
files_count: number;
|
||||
};
|
||||
|
||||
type NotificationLevel = 'default' | 'all' | 'mention' | 'none';
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ declare class ChannelInfoModel extends Model {
|
|||
/** pinned_post_count : The number of post pinned in this channel */
|
||||
pinnedPostCount: number;
|
||||
|
||||
filesCount: number;
|
||||
|
||||
/** purpose: The intention behind this channel */
|
||||
purpose: string;
|
||||
|
||||
|
|
|
|||
1
types/database/raw_values.d.ts
vendored
1
types/database/raw_values.d.ts
vendored
|
|
@ -13,6 +13,7 @@ type ChannelInfo = {
|
|||
header: string;
|
||||
member_count: number;
|
||||
pinned_post_count: number;
|
||||
files_count: number;
|
||||
purpose: string;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue