Skip to content

Commit 5c6ac58

Browse files
committed
Add views attribute to SiteVisitStatsItem in storage
1 parent 309a5ed commit 5c6ac58

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

Networking/NetworkingTests/Responses/site-visits-alt.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"data": [
1414
[
1515
"2014-01-01",
16-
12821,
16+
12831,
1717
1140,
1818
1094,
1919
0,
@@ -22,7 +22,7 @@
2222
],
2323
[
2424
"2015-01-01",
25-
14808,
25+
14818,
2626
1634,
2727
1492,
2828
0,

Storage/Storage/Model/MIGRATIONS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.
44

5+
## Model 79 (Release 11.7.0.0)
6+
- @rachelmcr 2022-12-12
7+
- Added `views` attribute to `SiteVisitStatsItem` entity.
8+
59
## Model 78 (Release 11.4.0.0)
610
- @rachelmcr 2022-11-18
711
- Added `averageOrderValue` attribute to `OrderStatsV4Totals` entity.

Storage/Storage/Model/SiteVisitStatsItem+CoreDataProperties.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ extension SiteVisitStatsItem {
1010

1111
@NSManaged public var period: String?
1212
@NSManaged public var visitors: Int64
13+
@NSManaged public var views: Int64
1314
@NSManaged public var stats: SiteVisitStats?
1415
}

Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 79.xcdatamodel/contents

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@
756756
</entity>
757757
<entity name="SiteVisitStatsItem" representedClassName="SiteVisitStatsItem" syncable="YES">
758758
<attribute name="period" optional="YES" attributeType="String"/>
759+
<attribute name="views" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
759760
<attribute name="visitors" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
760761
<relationship name="stats" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="SiteVisitStats" inverseName="items" inverseEntity="SiteVisitStats"/>
761762
</entity>

Yosemite/Yosemite/Model/Storage/SiteVisitStatsItem+ReadOnlyConvertible.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ extension Storage.SiteVisitStatsItem: ReadOnlyConvertible {
1111
public func update(with statsItem: Yosemite.SiteVisitStatsItem) {
1212
period = statsItem.period
1313
visitors = Int64(statsItem.visitors)
14+
views = Int64(statsItem.views)
1415
}
1516

1617
/// Returns a ReadOnly version of the receiver.
1718
///
1819
public func toReadOnly() -> Yosemite.SiteVisitStatsItem {
1920
return SiteVisitStatsItem(period: period ?? "",
2021
visitors: Int(visitors),
21-
views: 0) // TODO-8363: Update Storage with views count
22+
views: Int(views))
2223
}
2324
}

Yosemite/YosemiteTests/Stores/StatsStoreV4Tests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,11 @@ private extension StatsStoreV4Tests {
603603

604604

605605
func sampleSiteVisitStatsItem1() -> Networking.SiteVisitStatsItem {
606-
return SiteVisitStatsItem(period: "2014-01-01", visitors: 1135, views: 0)
606+
return SiteVisitStatsItem(period: "2014-01-01", visitors: 1135, views: 12821)
607607
}
608608

609609
func sampleSiteVisitStatsItem2() -> Networking.SiteVisitStatsItem {
610-
return SiteVisitStatsItem(period: "2015-01-01", visitors: 1629, views: 0)
610+
return SiteVisitStatsItem(period: "2015-01-01", visitors: 1629, views: 14808)
611611
}
612612

613613
func sampleSiteVisitStatsMutated() -> Networking.SiteVisitStats {
@@ -619,11 +619,11 @@ private extension StatsStoreV4Tests {
619619

620620

621621
func sampleSiteVisitStatsItem1Mutated() -> Networking.SiteVisitStatsItem {
622-
return SiteVisitStatsItem(period: "2014-01-01", visitors: 1140, views: 0)
622+
return SiteVisitStatsItem(period: "2014-01-01", visitors: 1140, views: 12831)
623623
}
624624

625625
func sampleSiteVisitStatsItem2Mutated() -> Networking.SiteVisitStatsItem {
626-
return SiteVisitStatsItem(period: "2015-01-01", visitors: 1634, views: 0)
626+
return SiteVisitStatsItem(period: "2015-01-01", visitors: 1634, views: 14818)
627627
}
628628

629629
// MARK: - Top Earner Stats Sample

0 commit comments

Comments
 (0)