Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Networking/Networking.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
748D424A210F92EA00CF7D1B /* OrderStatsItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 748D4249210F92EA00CF7D1B /* OrderStatsItem.swift */; };
748D424C210FA34400CF7D1B /* OrderStatsMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 748D424B210FA34400CF7D1B /* OrderStatsMapper.swift */; };
748D424E210FB1F500CF7D1B /* order-stats-day.json in Resources */ = {isa = PBXBuildFile; fileRef = 748D424D210FB1F500CF7D1B /* order-stats-day.json */; };
7497376A2141F2BE0008C490 /* top-performers-week-alt.json in Resources */ = {isa = PBXBuildFile; fileRef = 749737692141F2BE0008C490 /* top-performers-week-alt.json */; };
74A1196C2110F4BB00E1E5F0 /* OrderStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74A1196B2110F4BB00E1E5F0 /* OrderStats.swift */; };
74A1D263211898F000931DFA /* site-visits-day.json in Resources */ = {isa = PBXBuildFile; fileRef = 74A1D25F211898F000931DFA /* site-visits-day.json */; };
74A1D264211898F000931DFA /* site-visits-week.json in Resources */ = {isa = PBXBuildFile; fileRef = 74A1D260211898F000931DFA /* site-visits-week.json */; };
Expand Down Expand Up @@ -132,6 +133,7 @@
748D4249210F92EA00CF7D1B /* OrderStatsItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderStatsItem.swift; sourceTree = "<group>"; };
748D424B210FA34400CF7D1B /* OrderStatsMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderStatsMapper.swift; sourceTree = "<group>"; };
748D424D210FB1F500CF7D1B /* order-stats-day.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "order-stats-day.json"; sourceTree = "<group>"; };
749737692141F2BE0008C490 /* top-performers-week-alt.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "top-performers-week-alt.json"; sourceTree = "<group>"; };
74A1196B2110F4BB00E1E5F0 /* OrderStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderStats.swift; sourceTree = "<group>"; };
74A1D25F211898F000931DFA /* site-visits-day.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "site-visits-day.json"; sourceTree = "<group>"; };
74A1D260211898F000931DFA /* site-visits-week.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "site-visits-week.json"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -447,6 +449,7 @@
743BF8BD21191B63008A9D87 /* site-visits.json */,
74ABA1C4213F17AA00FFAD30 /* top-performers-day.json */,
74ABA1C8213F19FE00FFAD30 /* top-performers-week.json */,
749737692141F2BE0008C490 /* top-performers-week-alt.json */,
74ABA1C6213F19FD00FFAD30 /* top-performers-month.json */,
74ABA1C7213F19FE00FFAD30 /* top-performers-year.json */,
);
Expand Down Expand Up @@ -620,6 +623,7 @@
74ABA1C9213F19FE00FFAD30 /* top-performers-month.json in Resources */,
B58D10C82114D21D00107ED4 /* generic_error.json in Resources */,
B5147876211B9227007562E5 /* broken-orders-mark-2.json in Resources */,
7497376A2141F2BE0008C490 /* top-performers-week-alt.json in Resources */,
743BF8BE21191B63008A9D87 /* site-visits.json in Resources */,
B505F6D520BEE4E700BB1B69 /* me.json in Resources */,
B5C6FCD620A3768900A4F8E4 /* order.json in Resources */,
Expand Down
3 changes: 2 additions & 1 deletion Networking/Networking/Model/Stats/TopEarnerStats.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ extension TopEarnerStats: Comparable {
return lhs.date == rhs.date &&
lhs.granularity == rhs.granularity &&
lhs.limit == rhs.limit &&
lhs.items == rhs.items
lhs.items?.count == rhs.items?.count &&
lhs.items?.sorted() == rhs.items?.sorted()
}

public static func < (lhs: TopEarnerStats, rhs: TopEarnerStats) -> Bool {
Expand Down
25 changes: 25 additions & 0 deletions Networking/NetworkingTests/Responses/top-performers-week-alt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"date": "2018-W12",
"unit": "week",
"limit": "4",
"data": [
{
"ID": 996,
"name": "Funky Hoodie 2",
"total": 2,
"quantity": 444,
"price": 40,
"image": "https:\/\/jamosova3.mystagingwebsite.com\/wp-content\/uploads\/2017\/05\/hoodie-with-logo.jpg",
"currency": "USD"
},
{
"ID": 933,
"name": "Smile T-Shirt 2",
"total": 161.00,
"quantity": 555,
"price": 55.44,
"image": "https:\/\/jamosova3.mystagingwebsite.com\/wp-content\/uploads\/2018\/04\/smile.gif",
"currency": "USD"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"currency": "USD"
}
]
}
}
22 changes: 21 additions & 1 deletion Storage/Storage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
7426A05120F69D00002A4E07 /* OrderCoupon+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7426A04F20F69D00002A4E07 /* OrderCoupon+CoreDataProperties.swift */; };
7426A05420F69DA4002A4E07 /* OrderItem+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7426A05220F69DA4002A4E07 /* OrderItem+CoreDataClass.swift */; };
7426A05520F69DA4002A4E07 /* OrderItem+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7426A05320F69DA4002A4E07 /* OrderItem+CoreDataProperties.swift */; };
746A9D21214078080013F6FF /* TopEarnerStats+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 746A9D1D214078080013F6FF /* TopEarnerStats+CoreDataClass.swift */; };
746A9D22214078080013F6FF /* TopEarnerStats+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 746A9D1E214078080013F6FF /* TopEarnerStats+CoreDataProperties.swift */; };
746A9D23214078080013F6FF /* TopEarnerStatsItem+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 746A9D1F214078080013F6FF /* TopEarnerStatsItem+CoreDataClass.swift */; };
746A9D24214078080013F6FF /* TopEarnerStatsItem+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 746A9D20214078080013F6FF /* TopEarnerStatsItem+CoreDataProperties.swift */; };
74B7D6AD20F90CBB002667AC /* OrderNote+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B7D6AB20F90CBB002667AC /* OrderNote+CoreDataClass.swift */; };
74B7D6AE20F90CBB002667AC /* OrderNote+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B7D6AC20F90CBB002667AC /* OrderNote+CoreDataProperties.swift */; };
B505255420EE6914008090F5 /* StorageType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505255320EE6914008090F5 /* StorageType+Extensions.swift */; };
Expand Down Expand Up @@ -59,6 +63,12 @@
7426A04F20F69D00002A4E07 /* OrderCoupon+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderCoupon+CoreDataProperties.swift"; sourceTree = "<group>"; };
7426A05220F69DA4002A4E07 /* OrderItem+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderItem+CoreDataClass.swift"; sourceTree = "<group>"; };
7426A05320F69DA4002A4E07 /* OrderItem+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderItem+CoreDataProperties.swift"; sourceTree = "<group>"; };
746A9D12214071EB0013F6FF /* MIGRATIONS.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = MIGRATIONS.md; sourceTree = "<group>"; };
746A9D14214071F90013F6FF /* Model 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 2.xcdatamodel"; sourceTree = "<group>"; };
746A9D1D214078080013F6FF /* TopEarnerStats+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TopEarnerStats+CoreDataClass.swift"; sourceTree = "<group>"; };
746A9D1E214078080013F6FF /* TopEarnerStats+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TopEarnerStats+CoreDataProperties.swift"; sourceTree = "<group>"; };
746A9D1F214078080013F6FF /* TopEarnerStatsItem+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TopEarnerStatsItem+CoreDataClass.swift"; sourceTree = "<group>"; };
746A9D20214078080013F6FF /* TopEarnerStatsItem+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TopEarnerStatsItem+CoreDataProperties.swift"; sourceTree = "<group>"; };
74B7D6AB20F90CBB002667AC /* OrderNote+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderNote+CoreDataClass.swift"; sourceTree = "<group>"; };
74B7D6AC20F90CBB002667AC /* OrderNote+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderNote+CoreDataProperties.swift"; sourceTree = "<group>"; };
7C81935EDD982072BBDCC837 /* Pods-Storage.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Storage.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Storage/Pods-Storage.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -236,6 +246,7 @@
B59E11D720A9CFF3004121A4 /* Model */ = {
isa = PBXGroup;
children = (
746A9D12214071EB0013F6FF /* MIGRATIONS.md */,
B59E11D820A9D00C004121A4 /* WooCommerce.xcdatamodeld */,
B505F6D920BEEA3200BB1B69 /* Account+CoreDataClass.swift */,
B505F6D820BEEA3100BB1B69 /* Account+CoreDataProperties.swift */,
Expand All @@ -249,6 +260,10 @@
7426A05320F69DA4002A4E07 /* OrderItem+CoreDataProperties.swift */,
74B7D6AB20F90CBB002667AC /* OrderNote+CoreDataClass.swift */,
74B7D6AC20F90CBB002667AC /* OrderNote+CoreDataProperties.swift */,
746A9D1D214078080013F6FF /* TopEarnerStats+CoreDataClass.swift */,
746A9D1E214078080013F6FF /* TopEarnerStats+CoreDataProperties.swift */,
746A9D1F214078080013F6FF /* TopEarnerStatsItem+CoreDataClass.swift */,
746A9D20214078080013F6FF /* TopEarnerStatsItem+CoreDataProperties.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -441,17 +456,21 @@
7426A05520F69DA4002A4E07 /* OrderItem+CoreDataProperties.swift in Sources */,
7426A04720F68F27002A4E07 /* Order+CoreDataClass.swift in Sources */,
B54CA5BD20A4BD3B00F38CD1 /* NSManagedObjectContext+Storage.swift in Sources */,
746A9D21214078080013F6FF /* TopEarnerStats+CoreDataClass.swift in Sources */,
74B7D6AD20F90CBB002667AC /* OrderNote+CoreDataClass.swift in Sources */,
B52B0F7920AA287C00477698 /* StorageManagerType.swift in Sources */,
7426A05420F69DA4002A4E07 /* OrderItem+CoreDataClass.swift in Sources */,
B505F6E020BEEA8100BB1B69 /* StorageType.swift in Sources */,
746A9D22214078080013F6FF /* TopEarnerStats+CoreDataProperties.swift in Sources */,
B54CA5C920A4C17800F38CD1 /* NSObject+Storage.swift in Sources */,
B505F6DA20BEEA3200BB1B69 /* Account+CoreDataProperties.swift in Sources */,
74B7D6AE20F90CBB002667AC /* OrderNote+CoreDataProperties.swift in Sources */,
B505255420EE6914008090F5 /* StorageType+Extensions.swift in Sources */,
B52B0F7B20AA28A800477698 /* Object.swift in Sources */,
7426A05020F69D00002A4E07 /* OrderCoupon+CoreDataClass.swift in Sources */,
746A9D23214078080013F6FF /* TopEarnerStatsItem+CoreDataClass.swift in Sources */,
B505F6DE20BEEA4F00BB1B69 /* CoreDataManager.swift in Sources */,
746A9D24214078080013F6FF /* TopEarnerStatsItem+CoreDataProperties.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -742,9 +761,10 @@
B59E11D820A9D00C004121A4 /* WooCommerce.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
746A9D14214071F90013F6FF /* Model 2.xcdatamodel */,
B59E11D920A9D00C004121A4 /* Model.xcdatamodel */,
);
currentVersion = B59E11D920A9D00C004121A4 /* Model.xcdatamodel */;
currentVersion = 746A9D14214071F90013F6FF /* Model 2.xcdatamodel */;
path = WooCommerce.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
8 changes: 8 additions & 0 deletions Storage/Storage/Model/MIGRATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Core Data Migrations

This file documents changes in the extensions data model. Please explain any changes to the data model as well as any custom migrations.

## Model 2
- @bummytime 2018-09-05
- Added new entity: `TopEarnerStats`, to encapsulate all of the top earner stats for a given site & granularity
- Added new entity: `TopEarnerStatsItem`, to encapsulate all the top earner stats for a specific product
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!!!!

7 changes: 7 additions & 0 deletions Storage/Storage/Model/TopEarnerStats+CoreDataClass.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation
import CoreData

@objc(TopEarnerStats)
public class TopEarnerStats: NSManagedObject {

}
31 changes: 31 additions & 0 deletions Storage/Storage/Model/TopEarnerStats+CoreDataProperties.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Foundation
import CoreData


extension TopEarnerStats {

@nonobjc public class func fetchRequest() -> NSFetchRequest<TopEarnerStats> {
return NSFetchRequest<TopEarnerStats>(entityName: "TopEarnerStats")
}

@NSManaged public var granularity: String
@NSManaged public var limit: String
@NSManaged public var date: String
@NSManaged public var items: Set<TopEarnerStatsItem>?
}

// MARK: Generated accessors for items
extension TopEarnerStats {

@objc(addItemsObject:)
@NSManaged public func addToItems(_ value: TopEarnerStatsItem)

@objc(removeItemsObject:)
@NSManaged public func removeFromItems(_ value: TopEarnerStatsItem)

@objc(addItems:)
@NSManaged public func addToItems(_ values: NSSet)

@objc(removeItems:)
@NSManaged public func removeFromItems(_ values: NSSet)
}
7 changes: 7 additions & 0 deletions Storage/Storage/Model/TopEarnerStatsItem+CoreDataClass.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation
import CoreData

@objc(TopEarnerStatsItem)
public class TopEarnerStatsItem: NSManagedObject {

}
19 changes: 19 additions & 0 deletions Storage/Storage/Model/TopEarnerStatsItem+CoreDataProperties.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation
import CoreData


extension TopEarnerStatsItem {

@nonobjc public class func fetchRequest() -> NSFetchRequest<TopEarnerStatsItem> {
return NSFetchRequest<TopEarnerStatsItem>(entityName: "TopEarnerStatsItem")
}

@NSManaged public var productID: Int64
@NSManaged public var productName: String?
@NSManaged public var quantity: Int16
@NSManaged public var price: Double
@NSManaged public var total: Double
@NSManaged public var currency: String?
@NSManaged public var imageUrl: String?
@NSManaged public var stats: TopEarnerStats?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Model 2.xcdatamodel</string>
</dict>
</plist>
Loading