diff --git a/apps/profile/middleware.py b/apps/profile/middleware.py index c84699553..b21447920 100644 --- a/apps/profile/middleware.py +++ b/apps/profile/middleware.py @@ -74,7 +74,7 @@ class DBProfilerMiddleware: class SQLLogToConsoleMiddleware: def activated(self, request): - return (settings.DEBUG or + return (settings.DEBUG_QUERIES or (hasattr(request, 'activated_segments') and 'db_profiler' in request.activated_segments)) diff --git a/clients/ios/Classes/FolderTitleView.m b/clients/ios/Classes/FolderTitleView.m index ab443bec7..c2e4680c1 100644 --- a/clients/ios/Classes/FolderTitleView.m +++ b/clients/ios/Classes/FolderTitleView.m @@ -172,7 +172,7 @@ disclosureButton.frame = CGRectMake(customView.frame.size.width - 32, 3, 29, 29); // Add collapse button to all folders except Everything - if (section != 0 && section != 2 && ![folderName isEqual:@"saved_stories"]) { + if (section != 0 && section != 2) { if (!isFolderCollapsed) { UIImage *disclosureImage = [UIImage imageNamed:@"disclosure_down.png"]; [disclosureButton setImage:disclosureImage forState:UIControlStateNormal]; diff --git a/clients/ios/Classes/NewsBlurAppDelegate.h b/clients/ios/Classes/NewsBlurAppDelegate.h index 124b59d53..08012600f 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.h +++ b/clients/ios/Classes/NewsBlurAppDelegate.h @@ -213,6 +213,7 @@ @property (nonatomic, strong) NSMutableDictionary *dictFeeds; @property (nonatomic) NSMutableDictionary *dictActiveFeeds; @property (nonatomic) NSDictionary *dictSocialFeeds; +@property (nonatomic) NSDictionary *dictSavedStoryTags; @property (nonatomic) NSDictionary *dictSocialProfile; @property (nonatomic) NSDictionary *dictUserProfile; @property (nonatomic) NSDictionary *dictSocialServices; @@ -283,6 +284,7 @@ - (void)hideShareView:(BOOL)resetComment; - (void)resetShareComments; - (BOOL)isSocialFeed:(NSString *)feedIdStr; +- (BOOL)isSavedFeed:(NSString *)feedIdStr; - (BOOL)isPortrait; - (void)confirmLogout; - (void)showConnectToService:(NSString *)serviceName; diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index 521fe08a8..6c467e2d4 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -129,6 +129,7 @@ @synthesize dictFeeds; @synthesize dictActiveFeeds; @synthesize dictSocialFeeds; +@synthesize dictSavedStoryTags; @synthesize dictSocialProfile; @synthesize dictUserProfile; @synthesize dictSocialServices; @@ -714,6 +715,7 @@ - (void)showLogin { self.dictFeeds = nil; self.dictSocialFeeds = nil; + self.dictSavedStoryTags = nil; self.dictFolders = nil; self.dictFoldersArray = nil; self.userActivitiesArray = nil; @@ -952,6 +954,10 @@ return NO; } +- (BOOL)isSavedFeed:(NSString *)feedIdStr { + return [feedIdStr startsWith:@"saved:"]; +} + - (BOOL)isPortrait { UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { @@ -1100,12 +1106,12 @@ // add all the feeds from every NON blurblog folder [feedDetailView.storiesCollection setActiveFolder:@"everything"]; for (NSString *folderName in self.feedsViewController.activeFeedLocations) { - if (![folderName isEqualToString:@"river_blurblogs"]) { - NSArray *originalFolder = [self.dictFolders objectForKey:folderName]; - NSArray *folderFeeds = [self.feedsViewController.activeFeedLocations objectForKey:folderName]; - for (int l=0; l < [folderFeeds count]; l++) { - [feeds addObject:[originalFolder objectAtIndex:[[folderFeeds objectAtIndex:l] intValue]]]; - } + if ([folderName isEqualToString:@"river_blurblogs"]) continue; + if ([folderName isEqualToString:@"saved_stories"]) continue; + NSArray *originalFolder = [self.dictFolders objectForKey:folderName]; + NSArray *folderFeeds = [self.feedsViewController.activeFeedLocations objectForKey:folderName]; + for (int l=0; l < [folderFeeds count]; l++) { + [feeds addObject:[originalFolder objectAtIndex:[[folderFeeds objectAtIndex:l] intValue]]]; } } [self.folderCountCache removeAllObjects]; @@ -1380,9 +1386,7 @@ #pragma mark - Unread Counts -- (void)populateDictUnreadCounts { - self.dictUnreadCounts = [NSMutableDictionary dictionary]; - +- (void)populateDictUnreadCounts { [self.database inDatabase:^(FMDatabase *db) { FMResultSet *cursor = [db executeQuery:@"SELECT * FROM unread_counts"]; diff --git a/clients/ios/Classes/NewsBlurViewController.m b/clients/ios/Classes/NewsBlurViewController.m index 820323e11..f359a4218 100644 --- a/clients/ios/Classes/NewsBlurViewController.m +++ b/clients/ios/Classes/NewsBlurViewController.m @@ -489,7 +489,6 @@ static UIFont *userLabelFont; - (void)finishLoadingFeedListWithDict:(NSDictionary *)results finished:(BOOL)finished { NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults]; - appDelegate.savedStoriesCount = [[results objectForKey:@"starred_count"] intValue]; [MBProgressHUD hideHUDForView:self.view animated:YES]; self.stillVisibleFeeds = [NSMutableDictionary dictionary]; @@ -545,6 +544,7 @@ static UIFont *userLabelFont; NSArray *sortedArray; // Set up dictSocialProfile and userActivitiesArray + appDelegate.dictUnreadCounts = [NSMutableDictionary dictionary]; appDelegate.dictSocialProfile = [results objectForKey:@"social_profile"]; appDelegate.dictUserProfile = [results objectForKey:@"user_profile"]; appDelegate.dictSocialServices = [results objectForKey:@"social_services"]; @@ -554,6 +554,7 @@ static UIFont *userLabelFont; NSArray *socialFeedsArray = [results objectForKey:@"social_feeds"]; NSMutableArray *socialFolder = [[NSMutableArray alloc] init]; NSMutableDictionary *socialDict = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *savedStoryDict = [[NSMutableDictionary alloc] init]; NSMutableDictionary *tempActiveFeeds = [[NSMutableDictionary alloc] init]; appDelegate.dictActiveFeeds = tempActiveFeeds; @@ -577,8 +578,23 @@ static UIFont *userLabelFont; [allFolders setValue:socialFolder forKey:@"river_blurblogs"]; [allFolders setValue:[[NSMutableArray alloc] init] forKey:@"river_global"]; + appDelegate.savedStoriesCount = [[results objectForKey:@"starred_count"] intValue]; if (appDelegate.savedStoriesCount) { - [allFolders setValue:[[NSArray alloc] init] forKey:@"saved_stories"]; + NSMutableArray *savedStories = [NSMutableArray array]; + for (NSDictionary *userTag in [results objectForKey:@"starred_counts"]) { + if ([[userTag objectForKey:@"tag"] isEqualToString:@""]) continue; + NSString *savedTagId = [NSString stringWithFormat:@"saved:%@", [userTag objectForKey:@"tag"]]; + NSDictionary *savedTag = @{@"ps": [userTag objectForKey:@"count"], + @"feed_title": [userTag objectForKey:@"tag"]}; + [savedStories addObject:savedTagId]; + [savedStoryDict setObject:savedTag forKey:savedTagId]; + [appDelegate.dictUnreadCounts setObject:@{@"ps": [userTag objectForKey:@"count"], + @"nt": [NSNumber numberWithInt:0], + @"ng": [NSNumber numberWithInt:0]} + forKey:savedTagId]; + } + [allFolders setValue:savedStories forKey:@"saved_stories"]; + appDelegate.dictSavedStoryTags = savedStoryDict; } appDelegate.dictFolders = allFolders; @@ -1035,7 +1051,7 @@ static UIFont *userLabelFont; } NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:section]; - + return [[appDelegate.dictFolders objectForKey:folderName] count]; } @@ -1045,6 +1061,7 @@ static UIFont *userLabelFont; id feedId = [[appDelegate.dictFolders objectForKey:folderName] objectAtIndex:indexPath.row]; NSString *feedIdStr = [NSString stringWithFormat:@"%@",feedId]; BOOL isSocial = [appDelegate isSocialFeed:feedIdStr]; + BOOL isSaved = [appDelegate isSavedFeed:feedIdStr]; NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults]; NSString *collapseKey = [NSString stringWithFormat:@"folderCollapsed:%@", folderName]; bool isFolderCollapsed = [userPreferences boolForKey:collapseKey]; @@ -1059,6 +1076,8 @@ static UIFont *userLabelFont; return cell; } else if (indexPath.section == 0 || indexPath.section == 1) { CellIdentifier = @"BlurblogCellIdentifier"; + } else if (isSaved) { + CellIdentifier = @"SavedCellIdentifier"; } else { CellIdentifier = @"FeedCellIdentifier"; } @@ -1071,8 +1090,13 @@ static UIFont *userLabelFont; cell.appDelegate = appDelegate; } + if (isSaved) { + NSLog(@"Saved: %@", [appDelegate.dictSavedStoryTags objectForKey:feedIdStr]); + } NSDictionary *feed = isSocial ? [appDelegate.dictSocialFeeds objectForKey:feedIdStr] : + isSaved ? + [appDelegate.dictSavedStoryTags objectForKey:feedIdStr] : [appDelegate.dictFeeds objectForKey:feedIdStr]; NSDictionary *unreadCounts = [appDelegate.dictUnreadCounts objectForKey:feedIdStr]; cell.feedFavicon = [appDelegate getFavicon:feedIdStr isSocial:isSocial]; @@ -1406,7 +1430,9 @@ heightForHeaderInSection:(NSInteger)section { feedId = [NSString stringWithFormat:@"%@",feedId]; } NSDictionary *unreadCounts = [appDelegate.dictUnreadCounts objectForKey:feedId]; - + if ([appDelegate isSavedFeed:feedId]) { + NSLog(@"is visible: %@? %@", feedId, unreadCounts); + } NSIndexPath *stillVisible = [self.stillVisibleFeeds objectForKey:feedId]; if (!stillVisible && appDelegate.selectedIntelligence >= 1 && @@ -1585,10 +1611,8 @@ heightForHeaderInSection:(NSInteger)section { } - (void)loadAvatars { - NSLog(@"loadAvatars pre"); dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul); dispatch_async(queue, ^{ - NSLog(@"loadAvatars start"); for (NSString *feed_id in [appDelegate.dictSocialFeeds allKeys]) { NSDictionary *feed = [appDelegate.dictSocialFeeds objectForKey:feed_id]; NSURL *imageURL = [NSURL URLWithString:[feed objectForKey:@"photo_url"]]; @@ -1601,9 +1625,7 @@ heightForHeaderInSection:(NSInteger)section { [appDelegate saveFavicon:faviconImage feedId:feed_id]; } - NSLog(@"loadAvatars end"); dispatch_async(dispatch_get_main_queue(), ^{ - NSLog(@"loadAvatars post"); [self.feedTitlesTable reloadData]; }); }); @@ -1614,7 +1636,6 @@ heightForHeaderInSection:(NSInteger)section { - (void)saveAndDrawFavicons:(ASIHTTPRequest *)request { __block NSString *responseString = [request responseString]; - NSLog(@"saveAndDrawFavicons pre"); dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul); dispatch_async(queue, ^{ NSData *responseData=[responseString dataUsingEncoding:NSUTF8StringEncoding]; @@ -1624,7 +1645,6 @@ heightForHeaderInSection:(NSInteger)section { options:kNilOptions error:&error]; - NSLog(@"saveAndDrawFavicons start"); for (id feed_id in results) { // NSMutableDictionary *feed = [[appDelegate.dictFeeds objectForKey:feed_id] mutableCopy]; // [feed setValue:[results objectForKey:feed_id] forKey:@"favicon"]; @@ -1639,9 +1659,7 @@ heightForHeaderInSection:(NSInteger)section { } } - NSLog(@"saveAndDrawFavicons end"); dispatch_async(dispatch_get_main_queue(), ^{ - NSLog(@"saveAndDrawFavicons post"); [self.feedTitlesTable reloadData]; [self loadAvatars]; }); diff --git a/clients/ios/NewsBlur_Prefix.pch b/clients/ios/NewsBlur_Prefix.pch index 61a690f4d..84c4b27cc 100644 --- a/clients/ios/NewsBlur_Prefix.pch +++ b/clients/ios/NewsBlur_Prefix.pch @@ -5,7 +5,7 @@ #import #import -//#define DEBUG 1 +#define DEBUG 1 //#define PROD_DEBUG 1 #ifdef DEBUG diff --git a/settings.py b/settings.py index df9c46e8b..670fdb492 100644 --- a/settings.py +++ b/settings.py @@ -57,6 +57,7 @@ SECRET_KEY = 'YOUR_SECRET_KEY' DEBUG = False TEST_DEBUG = False SEND_BROKEN_LINK_EMAILS = False +DEBUG_QUERIES = False MANAGERS = ADMINS PAYPAL_RECEIVER_EMAIL = 'samuel@ofbrooklyn.com' TIME_ZONE = 'GMT' diff --git a/utils/mongo_raw_log_middleware.py b/utils/mongo_raw_log_middleware.py index 4a2da70ef..6805a8a21 100644 --- a/utils/mongo_raw_log_middleware.py +++ b/utils/mongo_raw_log_middleware.py @@ -10,7 +10,7 @@ from bson.errors import InvalidBSON class MongoDumpMiddleware(object): def activated(self, request): - return (settings.DEBUG or + return (settings.DEBUG_QUERIES or (hasattr(request, 'activated_segments') and 'db_profiler' in request.activated_segments)) diff --git a/utils/redis_raw_log_middleware.py b/utils/redis_raw_log_middleware.py index af9b5fbd4..8af0fc244 100644 --- a/utils/redis_raw_log_middleware.py +++ b/utils/redis_raw_log_middleware.py @@ -6,7 +6,7 @@ from time import time class RedisDumpMiddleware(object): def activated(self, request): - return (settings.DEBUG or + return (settings.DEBUG_QUERIES or (hasattr(request, 'activated_segments') and 'db_profiler' in request.activated_segments))