/// <summary> /// Query count of likes for a content /// </summary> /// <param name="contentHandle">Content handle</param> /// <returns>Likes count for a content</returns> public async Task <long?> QueryLikesCount(string contentHandle) { CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Likes); CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.Likes, TableIdentifier.LikesCount) as CountTable; CountEntity countEntity = await store.QueryCountAsync(countTable, contentHandle, this.tableStoreManager.DefaultCountKey); if (countEntity == null) { return(null); } return((long)countEntity.Count); }
/// <summary> /// Query notifications count /// </summary> /// <param name="userHandle">User handle</param> /// <param name="appHandle">App handle</param> /// <returns>Notifications count</returns> public async Task <long?> QueryNotificationsCount(string userHandle, string appHandle) { CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Notifications); CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.Notifications, TableIdentifier.NotificationsCount) as CountTable; var result = await store.QueryCountAsync(countTable, userHandle, appHandle); if (result == null) { return(null); } return((long)result.Count); }
/// <summary> /// Query comment replies count /// </summary> /// <param name="commentHandle">Comment handle</param> /// <returns>Comment replies count</returns> public async Task <long?> QueryCommentRepliesCount(string commentHandle) { CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.CommentReplies); CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.CommentReplies, TableIdentifier.CommentRepliesCount) as CountTable; var result = await store.QueryCountAsync(countTable, commentHandle, this.tableStoreManager.DefaultCountKey); if (result == null) { return(null); } return((long)result.Count); }
/// <summary> /// Query count of pins for a user in an app /// </summary> /// <param name="userHandle">User handle</param> /// <param name="appHandle">App handle</param> /// <returns>Pin count for a user handle and app handle</returns> public async Task <long?> QueryPinsCount(string userHandle, string appHandle) { CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Pins); CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.Pins, TableIdentifier.PinsCount) as CountTable; CountEntity countEntity = await store.QueryCountAsync(countTable, userHandle, appHandle); if (countEntity == null) { return(null); } return((long)countEntity.Count); }
/// <summary> /// Query count of blocked users for a user in an app /// </summary> /// <param name="userHandle">User handle</param> /// <param name="appHandle">App handle</param> /// <returns>Blocked users count for a user handle and app handle</returns> public async Task <long?> QueryBlockedUsersCount(string userHandle, string appHandle) { CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserFollowers); CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserFollowers, TableIdentifier.FollowersCount) as CountTable; string countKey = this.GetCountKey(appHandle, UserRelationshipStatus.Blocked); CountEntity countEntity = await store.QueryCountAsync(countTable, userHandle, countKey); if (countEntity == null) { return(null); } return((long)countEntity.Count); }
/// <summary> /// Look up the number of unique users reporting against a particular user /// </summary> /// <param name="appHandle">uniquely identifies the app that the user is in</param> /// <param name="reportedUserHandle">uniquely identifies the user who is being reported</param> /// <returns>a task that returns the number of reports</returns> public async Task <long> QueryUserReportCount(string appHandle, string reportedUserHandle) { // get the table interface CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserReports); CountTable countByReportedUserTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsCountByReportedUser) as CountTable; // query the count CountEntity countEntity = await store.QueryCountAsync(countByReportedUserTable, appHandle, reportedUserHandle); if (countEntity == null || countEntity.PartitionKey != appHandle || countEntity.CountKey != reportedUserHandle) { return(0); } return(Convert.ToInt64(countEntity.Count)); }