Skip to content

Commit

Permalink
Release 1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chetanshanbagBV authored Jul 28, 2022
1 parent adf30bc commit e4e2ec7
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sonarscanCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: BVSwift Sonarqube Scan CI

on:
push:
branches: [ develop ]
branches: [ master ]
pull_request:
branches: [ develop ]
branches: [ master ]

env:
SONAR_LOGIN: ${{ secrets.SONAR_TOKEN }}
Expand Down
12 changes: 12 additions & 0 deletions BVSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
/* Begin PBXBuildFile section */
422C3B212538524900080544 /* BVCommentsQueryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 422C3B202538524900080544 /* BVCommentsQueryTest.swift */; };
42C3C3B62507951C00305A4C /* BVIncentivizedStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42C3C3B52507951C00305A4C /* BVIncentivizedStats.swift */; };
894615B228913424007B2138 /* BVCostomSort.swift in Sources */ = {isa = PBXBuildFile; fileRef = 894615B128913424007B2138 /* BVCostomSort.swift */; };
894615AE288FE812007B2138 /* BVRelevancySort.swift in Sources */ = {isa = PBXBuildFile; fileRef = 894615AD288FE812007B2138 /* BVRelevancySort.swift */; };
894615B0288FEB6B007B2138 /* BVRelevancySortOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 894615AF288FEB6B007B2138 /* BVRelevancySortOrder.swift */; };
895FB971279846BB0031DDED /* BVFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 895FB970279846BB0031DDED /* BVFeature.swift */; };
895FB972279847750031DDED /* BVFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98686C852407112F00D67889 /* BVFeedback.swift */; };
895FB97627994A300031DDED /* BVLanguageStat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 895FB97527994A300031DDED /* BVLanguageStat.swift */; };
Expand Down Expand Up @@ -296,6 +299,9 @@
/* Begin PBXFileReference section */
422C3B202538524900080544 /* BVCommentsQueryTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVCommentsQueryTest.swift; sourceTree = "<group>"; };
42C3C3B52507951C00305A4C /* BVIncentivizedStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVIncentivizedStats.swift; sourceTree = "<group>"; };
894615B128913424007B2138 /* BVCostomSort.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVCostomSort.swift; sourceTree = "<group>"; };
894615AD288FE812007B2138 /* BVRelevancySort.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVRelevancySort.swift; sourceTree = "<group>"; };
894615AF288FEB6B007B2138 /* BVRelevancySortOrder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVRelevancySortOrder.swift; sourceTree = "<group>"; };
895FB970279846BB0031DDED /* BVFeature.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BVFeature.swift; sourceTree = "<group>"; };
895FB97527994A300031DDED /* BVLanguageStat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVLanguageStat.swift; sourceTree = "<group>"; };
899900082706E45F0005275A /* BVFeatureQueryTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVFeatureQueryTest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -976,6 +982,7 @@
children = (
98686C342407109800D67889 /* BVConversationsFilterOperator.swift */,
98686C352407109900D67889 /* BVConversationsSortOrder.swift */,
894615AF288FEB6B007B2138 /* BVRelevancySortOrder.swift */,
B5B31EB520B373A3002DBEC8 /* Types */,
);
path = Fields;
Expand Down Expand Up @@ -1013,6 +1020,8 @@
895FB97527994A300031DDED /* BVLanguageStat.swift */,
89F1351D27FD92D4006BBBF5 /* BVSecondaryRatingStat.swift */,
89E3106E27F4C9F700D42042 /* BVTagStats.swift */,
894615B128913424007B2138 /* BVCostomSort.swift */,
894615AD288FE812007B2138 /* BVRelevancySort.swift */,
);
path = Types;
sourceTree = "<group>";
Expand Down Expand Up @@ -1507,11 +1516,13 @@
98686CAB2407113100D67889 /* BVDimensionElement.swift in Sources */,
98686CF92407120700D67889 /* BVCurationsFeedItem.swift in Sources */,
98686CEF2407120700D67889 /* BVCurationsCustomContent.swift in Sources */,
894615B228913424007B2138 /* BVCostomSort.swift in Sources */,
98686C0B2407100900D67889 /* BVURLRequestable.swift in Sources */,
98686C56240710AE00D67889 /* BVProductStat.swift in Sources */,
98686D352407132000D67889 /* BVRecommendationsProfileInclude.swift in Sources */,
98686CFD2407120700D67889 /* BVCurationsLink.swift in Sources */,
98686CA62407113100D67889 /* BVProductStatistics.swift in Sources */,
894615B0288FEB6B007B2138 /* BVRelevancySortOrder.swift in Sources */,
98686D2B240712F700D67889 /* BVRecommendationsError.swift in Sources */,
98686D362407132000D67889 /* BVRecommendationsProfilePurpose.swift in Sources */,
98686D2A240712F700D67889 /* BVRecommendationsConfiguration.swift in Sources */,
Expand Down Expand Up @@ -1595,6 +1606,7 @@
98686D1E240712BB00D67889 /* BVWeak.swift in Sources */,
98686C332407108600D67889 /* BVConversationsQueryResponse.swift in Sources */,
98686CD9240711EE00D67889 /* BVCurationsFeedItemQuery.swift in Sources */,
894615AE288FE812007B2138 /* BVRelevancySort.swift in Sources */,
98686CCD240711B800D67889 /* BVCurationsConstants.swift in Sources */,
98686D392407133500D67889 /* BVRecommendationsProfileQuery.swift in Sources */,
9F51CA49240CD1150043AED5 /* BVReviewHighlights.swift in Sources */,
Expand Down
11 changes: 8 additions & 3 deletions BVSwift/BVCommon/Logging/BVLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ public class BVLogger {
DispatchQueue(label: "com.bvswift.BVLogger.listenerQueue")

private var listeners = [BVLogNotifier]()

private var _logger : OSLog? = nil

@available(iOS 10.0, *)
lazy private var logger = {
return OSLog(subsystem: "com.bvswift.BVLogger", category: "Module")
}()
private var logger:OSLog {
if _logger == nil {
_logger = OSLog(subsystem: "com.bvswift.BVLogger", category: "Module")
}
return _logger!
}

private var internalLogLevel: LogLevel = .error

Expand Down
18 changes: 18 additions & 0 deletions BVSwift/BVCommon/Networking/BVURLParameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ internal indirect enum BVURLParameter: BVParameter {
CustomStringConvertible,
CustomStringConvertible,
BVURLParameter?)
case customSort(
BVQuerySort,
CustomStringConvertible,
BVURLParameter?)

var name: String {
switch self {
Expand Down Expand Up @@ -70,6 +74,8 @@ internal indirect enum BVURLParameter: BVParameter {
return type(of: stats).statPrefix.escaping()
case .unsafe(let field, _, _):
return field.description.escaping()
case .customSort(let sort, _, _):
return type(of: sort).sortPrefix.escaping()
}
}

Expand Down Expand Up @@ -119,6 +125,8 @@ internal indirect enum BVURLParameter: BVParameter {
self = .stats(stats, child)
case let .unsafe(field, value, _):
self = .unsafe(field, value, child)
case let .customSort(sort, op, _):
self = .customSort(sort, op, child)
}
}

Expand Down Expand Up @@ -186,6 +194,12 @@ internal indirect enum BVURLParameter: BVParameter {
return stats.description.escaping()
case .unsafe(_, let value, _):
return value.description.escaping()
case .customSort(let sort, let order, _):
let separator = type(of: sort).sortValueSeparator
return
[sort.description.escaping(),
order.description].joined(separator: separator)

}
}

Expand All @@ -209,6 +223,8 @@ internal indirect enum BVURLParameter: BVParameter {
return .stats(stats, nil)
case let .unsafe(field, value, _):
return .unsafe(field, value, nil)
case let .customSort(sort, op, _):
return .customSort(sort, op, nil)
}
}

Expand All @@ -232,6 +248,8 @@ internal indirect enum BVURLParameter: BVParameter {
return child
case .unsafe(_, _, let child):
return child
case .customSort(_, _, let child):
return child
}
}

Expand Down
8 changes: 8 additions & 0 deletions BVSwift/BVCommon/Query/BVQueryable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ public protocol BVQuerySortable {
func sort(_ on: Sort, order: Order) -> Self
}

/// Protocol definition for the behavior of adding sort filters
public protocol BVQueryCustomSortable {
associatedtype Sort: BVQuerySort

func coustomSort(_ on: Sort, contentLocales: [String]) -> Self
}


/// Protocol definition for the behavior of adding stat filters
public protocol BVQueryStatable {
associatedtype Stat: BVQueryStat
Expand Down
2 changes: 2 additions & 0 deletions BVSwift/BVConversations/BVConversationsConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ internal struct BVConversationsConstants {
internal struct BVConversationsSortOrder {
static let ascending: String = "asc"
static let descending: String = "desc"
static let orderTwo = "a2"
}

internal struct BVNativeReviews {
Expand Down Expand Up @@ -368,6 +369,7 @@ internal struct BVConversationsConstants {
static let submissionTime: String = "SubmissionTime"
static let totalCommentCount: String = "TotalCommentCount"
static let totalFeedbackCount: String = "TotalFeedbackCount"
static let relavancy: String = "relevancy"
static let totalNegativeFeedbackCount: String =
"TotalNegativeFeedbackCount"
static let totalPositiveFeedbackCount: String =
Expand Down
27 changes: 27 additions & 0 deletions BVSwift/BVConversations/Display/Fields/BVRelevancySortOrder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
//
// BVRelavancySortOrder.swift
// BVSwift
//
// Copyright © 2022 Bazaarvoice. All rights reserved.
//

import Foundation
/// An enum that represents a sorting mechanism that allows for relevancy sort type by
public enum BVRelencySortType: BVQuerySortOrder {
case a2

public var description: String {
return internalDescription
}
}

extension BVRelencySortType: BVConversationsQueryValue {
var internalDescription: String {
switch self {
case .a2:
return BVConversationsConstants.BVConversationsSortOrder.orderTwo
}
}
}

43 changes: 43 additions & 0 deletions BVSwift/BVConversations/Display/Fields/Types/BVCostomSort.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
//
// BVCostomSort.swift
// BVSwift
//
// Copyright © 2022 Bazaarvoice. All rights reserved.
//

import Foundation
/// An enum that represents the possible custom sorting comparators to filter on for
/// the BVReviewQuery
/// - Note:
/// \
/// Used for conformance with the BVQuerySortable protocol.
public enum BVCustomSort: BVQuerySort {

case contentLocale

public static var sortPrefix: String {
return BVConversationsConstants.BVQuerySort.defaultField
}

public static var sortTypeSeparator: String {
return BVConversationsConstants.BVQuerySort.typeSeparatorField
}

public static var sortValueSeparator: String {
return BVConversationsConstants.BVQuerySort.valueSeparatorField
}

public var description: String {
return internalDescription
}
}

extension BVCustomSort: BVConversationsQueryValue {
var internalDescription: String {
switch self {
case .contentLocale:
return BVConversationsConstants.BVReviews.Keys.contentLocale
}
}
}
45 changes: 45 additions & 0 deletions BVSwift/BVConversations/Display/Fields/Types/BVRelevancySort.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
//
// BVRelavancySort.swift
// BVSwift
//
// Copyright © 2022 Bazaarvoice. All rights reserved.
//

import Foundation

/// An enum that represents the possible relevancy sorting comparators to filter on for
/// the BVReviewQuery
/// - Note:
/// \
/// Used for conformance with the BVQuerySortable protocol.
public enum BVRelevancySort: BVQuerySort {

case relevancy

public static var sortPrefix: String {
return BVConversationsConstants.BVQuerySort.defaultField
}

public static var sortTypeSeparator: String {
return BVConversationsConstants.BVQuerySort.typeSeparatorField
}

public static var sortValueSeparator: String {
return BVConversationsConstants.BVQuerySort.valueSeparatorField
}

public var description: String {
return internalDescription
}
}

extension BVRelevancySort: BVConversationsQueryValue {
var internalDescription: String {
switch self {
case .relevancy:
return BVConversationsConstants.BVReviews.Keys.relavancy
}
}
}

20 changes: 19 additions & 1 deletion BVSwift/BVConversations/Display/Types/BVReviewQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,31 @@ extension BVReviewQuery: BVQueryIncludeable {
extension BVReviewQuery: BVQuerySortable {
public typealias Sort = BVReviewSort
public typealias Order = BVConversationsSortOrder

public typealias customSortOptions = BVCustomSort
public typealias RelavancySort = BVRelevancySort
public typealias RelanvancySortType = BVRelencySortType

@discardableResult
public func sort(_ on: Sort, order: Order) -> Self {
let internalSort: BVURLParameter = .sort(on, order, nil)
add(internalSort)
return self
}

@discardableResult
public func sort(_ on: customSortOptions, contentLocales: [String]) -> Self {
let contentLocale: String = (contentLocales.map{String($0)}).joined(separator: ",")
let internalSort: BVURLParameter = .customSort(on, contentLocale, nil)
add(internalSort)
return self
}

@discardableResult
public func sort(_ on: RelavancySort, order: RelanvancySortType) -> Self {
let internalSort: BVURLParameter = .sort(on, order, nil)
add(internalSort)
return self
}
}

// MARK: - BVReviewQuery: BVQueryStatable
Expand Down
24 changes: 24 additions & 0 deletions BVSwift/BVConversations/Display/Types/BVReviewSearchQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@ extension BVReviewSearchQuery: BVQueryFilteredStatable {
}
}

// MARK: - BVReviewSearchQuery: BVQuerySortable
extension BVReviewSearchQuery: BVQuerySortable {
public typealias Sort = BVReviewSort
public typealias Order = BVConversationsSortOrder
public typealias RelavancySort = BVRelevancySort
public typealias RelanvancySortType = BVRelencySortType



@discardableResult
public func sort(_ on: Sort, order: Order) -> Self {
let internalSort: BVURLParameter = .sort(on, order, nil)
add(internalSort)
return self
}

@discardableResult
public func sort(_ on: RelavancySort, order: RelanvancySortType) -> Self {
let internalSort: BVURLParameter = .sort(on, order, nil)
add(internalSort)
return self
}
}

// MARK: - BVReviewSearchQuery: BVQueryIncludeable
extension BVReviewSearchQuery: BVQueryIncludeable {
public typealias Include = BVReviewInclude
Expand Down
Loading

0 comments on commit e4e2ec7

Please sign in to comment.