Skip to content

Commit

Permalink
Merge pull request #38 from shankari/make_plugins_independent
Browse files Browse the repository at this point in the history
Address the issue with usercache entries growing continuously
  • Loading branch information
shankari authored Mar 30, 2020
2 parents 0c4bc7f + 3ca0481 commit 123a410
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
id="edu.berkeley.eecs.emission.cordova.usercache"
version="1.1.0">
version="1.1.1">

<name>UserCache</name>
<description>Cache messages to and from the server so that we can retrieve
Expand Down
14 changes: 12 additions & 2 deletions src/ios/BEMBuiltinUserCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,18 @@ - (void)syncServerToPhone:(NSArray*)documentArray {
}
}

+ (TimeQuery*) getTimeQuery:(NSArray*)pointList {
assert(pointList.count != 0);
// The array can contain entries other than points, such as configurations and consent documents.
+ (TimeQuery*) getTimeQuery:(NSArray*)entryList {
assert(entryList.count != 0);
[LocalNotificationManager addNotification:[NSString stringWithFormat:@"unfiltered entry list (length %lu) runs from %@ to %@", entryList.count, entryList[0], entryList[entryList.count - 1]]];
NSPredicate *nonRWPredicate =
[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return ![evaluatedObject[@"metadata"][@"type"] isEqual:RW_DOCUMENT_TYPE];
}];

NSArray* pointList = [entryList filteredArrayUsingPredicate:nonRWPredicate];
[LocalNotificationManager addNotification:[NSString stringWithFormat:@"filtered entry list (length %lu) runs from %@ to %@", pointList.count, pointList[0], pointList[pointList.count - 1]]];

Metadata* startMd = [Metadata new];
[DataUtils dictToWrapper:[pointList[0] objectForKey:METADATA_TAG] wrapper:startMd];
double start_ts = startMd.write_ts;
Expand Down

0 comments on commit 123a410

Please sign in to comment.