Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.8.1 #274

Merged
merged 7 commits into from
Nov 1, 2023
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: 2 additions & 2 deletions Mindbox.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "Mindbox"
spec.version = "2.8.0"
spec.version = "2.8.1"
spec.summary = "SDK for integration with Mindbox"
spec.description = "This library allows you to integrate data transfer to Mindbox Marketing Cloud"
spec.homepage = "https://github.com/mindbox-cloud/ios-sdk"
Expand All @@ -14,6 +14,6 @@ Pod::Spec.new do |spec|
'Mindbox' => ['Mindbox/**/*.xcassets', 'Mindbox/**/*.xcdatamodeld']
}
spec.swift_version = "5"
spec.dependency 'MindboxLogger', '0.0.4'
spec.dependency 'MindboxLogger', '0.0.5'

end
20 changes: 10 additions & 10 deletions Mindbox/Database/MBDatabaseRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MBDatabaseRepository {

// MARK: - CRUD operations
func create(event: Event) throws {
try context.performAndWait {
try context.mindboxPerformAndWait {
let entity = CDEvent(context: context)
entity.transactionId = event.transactionId
entity.timestamp = Date().timeIntervalSince1970
Expand All @@ -80,7 +80,7 @@ class MBDatabaseRepository {
}

func read(by transactionId: String) throws -> CDEvent? {
try context.performAndWait {
try context.mindboxPerformAndWait {
Logger.common(message: "Reading event with transactionId: \(transactionId)", level: .info, category: .database)
let request: NSFetchRequest<CDEvent> = CDEvent.fetchRequest(by: transactionId)
guard let entity = try findEvent(by: request) else {
Expand All @@ -93,7 +93,7 @@ class MBDatabaseRepository {
}

func update(event: Event) throws {
try context.performAndWait {
try context.mindboxPerformAndWait {
Logger.common(message: "Updating event with transactionId: \(event.transactionId)", level: .info, category: .database)
let request: NSFetchRequest<CDEvent> = CDEvent.fetchRequest(by: event.transactionId)
guard let entity = try findEvent(by: request) else {
Expand All @@ -106,7 +106,7 @@ class MBDatabaseRepository {
}

func delete(event: Event) throws {
try context.performAndWait {
try context.mindboxPerformAndWait {
Logger.common(message: "Deleting event with transactionId: \(event.transactionId)", level: .info, category: .database)
let request = CDEvent.fetchRequest(by: event.transactionId)
guard let entity = try findEvent(by: request) else {
Expand All @@ -119,7 +119,7 @@ class MBDatabaseRepository {
}

func query(fetchLimit: Int, retryDeadline: TimeInterval = 60) throws -> [Event] {
try context.performAndWait {
try context.mindboxPerformAndWait {
Logger.common(message: "Quering events with fetchLimit: \(fetchLimit)", level: .info, category: .database)
let request: NSFetchRequest<CDEvent> = CDEvent.fetchRequestForSend(lifeLimitDate: lifeLimitDate, retryDeadLine: retryDeadline)
request.fetchLimit = fetchLimit
Expand Down Expand Up @@ -149,7 +149,7 @@ class MBDatabaseRepository {
func countDeprecatedEvents() throws -> Int {
let context = persistentContainer.newBackgroundContext()
let request: NSFetchRequest<CDEvent> = CDEvent.deprecatedEventsFetchRequest(lifeLimitDate: lifeLimitDate)
return try context.performAndWait {
return try context.mindboxPerformAndWait {
Logger.common(message: "Counting deprecated elements", level: .info, category: .database)
do {
let count = try context.count(for: request)
Expand All @@ -167,7 +167,7 @@ class MBDatabaseRepository {
let eraseRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest)
infoUpdateVersion = nil
installVersion = nil
try context.performAndWait {
try context.mindboxPerformAndWait {
try context.execute(eraseRequest)
try saveEvent(withContext: context)
try countEvents()
Expand All @@ -177,7 +177,7 @@ class MBDatabaseRepository {
@discardableResult
func countEvents() throws -> Int {
let request: NSFetchRequest<CDEvent> = CDEvent.countEventsFetchRequest()
return try context.performAndWait {
return try context.mindboxPerformAndWait {
Logger.common(message: "Events count limit: \(limit)", level: .info, category: .database)
Logger.common(message: "Counting events...", level: .info, category: .database)
do {
Expand Down Expand Up @@ -206,7 +206,7 @@ class MBDatabaseRepository {
}

private func delete(by request: NSFetchRequest<CDEvent>, withContext context: NSManagedObjectContext) throws {
try context.performAndWait {
try context.mindboxPerformAndWait {
Logger.common(message: "Finding elements to remove", level: .info, category: .database)

let events = try context.fetch(request)
Expand Down Expand Up @@ -275,7 +275,7 @@ private extension MBDatabaseRepository {
store.metadata[key.rawValue] = value
persistentContainer.persistentStoreCoordinator.setMetadata(store.metadata, for: store)
do {
try context.performAndWait {
try context.mindboxPerformAndWait {
try saveContext(context)
Logger.common(message: "Did save metadata of \(key.rawValue) to: \(String(describing: value))", level: .info, category: .database) }
} catch {
Expand Down
2 changes: 1 addition & 1 deletion Mindbox/Mindbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Mindbox: NSObject {
- In __RELEASE__ schema logs writes _async_ on queue with __qos: .utility__

- Warninig:
By default _logLevel_: __.none__
By default _logLevel_: __.error__
*/
public static let logger = MBLogger.shared

Expand Down
2 changes: 1 addition & 1 deletion MindboxLogger.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "MindboxLogger"
spec.version = "0.0.4"
spec.version = "0.0.5"
spec.summary = "SDK for utilities to work with Mindbox"
spec.description = "-"
spec.homepage = "https://github.com/mindbox-cloud/ios-sdk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import CoreData

public extension NSManagedObjectContext {
func performAndWait<T>(_ block: () throws -> T) rethrows -> T {
func mindboxPerformAndWait<T>(_ block: () throws -> T) rethrows -> T {
return try _performAndWaitHelper(
fn: performAndWait, execute: block, rescue: { throw $0 }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class MBLoggerCoreDataManager {
try delete()
}

try self.context.performAndWait {
try self.context.mindboxPerformAndWait {
let entity = CDLogMessage(context: self.context)
entity.message = message
entity.timestamp = timestamp
Expand All @@ -84,7 +84,7 @@ public class MBLoggerCoreDataManager {
}

public func getFirstLog() throws -> LogMessage? {
try context.performAndWait {
try context.mindboxPerformAndWait {
let fetchRequest = NSFetchRequest<CDLogMessage>(entityName: Constants.model)
fetchRequest.predicate = NSPredicate(value: true)
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "timestamp", ascending: true)]
Expand All @@ -100,7 +100,7 @@ public class MBLoggerCoreDataManager {
}

public func getLastLog() throws -> LogMessage? {
try context.performAndWait {
try context.mindboxPerformAndWait {
let fetchRequest = NSFetchRequest<CDLogMessage>(entityName: Constants.model)
fetchRequest.predicate = NSPredicate(value: true)
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "timestamp", ascending: false)]
Expand All @@ -116,7 +116,7 @@ public class MBLoggerCoreDataManager {
}

public func fetchPeriod(_ from: Date, _ to: Date) throws -> [LogMessage] {
try context.performAndWait {
try context.mindboxPerformAndWait {
let fetchRequest = NSFetchRequest<CDLogMessage>(entityName: Constants.model)
fetchRequest.predicate = NSPredicate(format: "timestamp >= %@ AND timestamp <= %@",
from as NSDate,
Expand All @@ -132,7 +132,7 @@ public class MBLoggerCoreDataManager {
}

public func delete() throws {
try context.performAndWait {
try context.mindboxPerformAndWait {
let request = NSFetchRequest<NSFetchRequestResult>(entityName: Constants.model)
let count = try context.count(for: request)
let limit: Double = (Double(count) * 0.1).rounded() // 10% percent of all records should be removed
Expand All @@ -152,7 +152,7 @@ public class MBLoggerCoreDataManager {
}

public func deleteAll() throws {
try context.performAndWait {
try context.mindboxPerformAndWait {
let request = NSFetchRequest<NSFetchRequestResult>(entityName: Constants.model)
request.includesPropertyValues = false
let results = try context.fetch(request)
Expand Down
2 changes: 1 addition & 1 deletion MindboxLogger/Shared/MBLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MBLogger {

- Note: `.error` by default; `.none` for disable logging
*/
public var logLevel: LogLevel = .debug
public var logLevel: LogLevel = .error

private enum ExecutionMethod {
case sync(lock: NSRecursiveLock)
Expand Down
4 changes: 2 additions & 2 deletions MindboxNotifications.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "MindboxNotifications"
spec.version = "2.8.0"
spec.version = "2.8.1"
spec.summary = "SDK for integration notifications with Mindbox"
spec.description = "This library allows you to integrate notifications and transfer them to Mindbox Marketing Cloud"
spec.homepage = "https://github.com/mindbox-cloud/ios-sdk"
Expand All @@ -11,6 +11,6 @@ Pod::Spec.new do |spec|
spec.source_files = "MindboxNotifications/**/*.{swift}", "SDKVersionProvider/**/*.{swift}"
spec.exclude_files = "Classes/Exclude"
spec.swift_version = "5"
spec.dependency 'MindboxLogger', '0.0.4'
spec.dependency 'MindboxLogger', '0.0.5'

end
2 changes: 1 addition & 1 deletion SDKVersionProvider/SDKVersionConfig.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 2.8.0
MARKETING_VERSION = 2.8.1
2 changes: 1 addition & 1 deletion SDKVersionProvider/SDKVersionProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import Foundation

public class SDKVersionProvider {
public static let sdkVersion = "2.8.0"
public static let sdkVersion = "2.8.1"
}
18 changes: 14 additions & 4 deletions git-release-branch-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ git checkout $branch_name
#Add changelog to the index and create a commit
podspec_file="Mindbox.podspec"
notifivation_podspec_file="MindboxNotifications.podspec"
sdkversionprovider_file="SDKVersionProvider.swift"
sdkversionprovider_file="SDKVersionProvider/SDKVersionProvider.swift"
sdkversionconfig_file="SDKVersionProvider/SDKVersionConfig.xcconfig"
current_version=$(grep -E '^\s+spec.version\s+=' "$podspec_file" | cut -d'"' -f2)
sed -i '' "s/^ spec.version = ."$/ spec.version = "$version"/" $podspec_file
sed -i '' "s/^ spec.version = ."$/ spec.version = "$version"/" $notifivation_podspec_file
sed -i '' "s/public static let sdkVersion = ".*"$/public static let sdkVersion = "$version"/" $sdkversionprovider_file

# Обновление версии в Mindbox.podspec
sed -i '' "s/^[[:space:]]*spec.version[[:space:]]*=[[:space:]]*\".*\"$/ spec.version = \"$version\"/" $podspec_file

# Обновление версии в MindboxNotifications.podspec
sed -i '' "s/^[[:space:]]*spec.version[[:space:]]*=[[:space:]]*\".*\"$/ spec.version = \"$version\"/" $notifivation_podspec_file

# Обновление версии в SDKVersionProvider.swift
sed -i '' "s/public static let sdkVersion = \".*\"$/public static let sdkVersion = \"$version\"/" $sdkversionprovider_file

# Обновление MARKETING_VERSION в SDKVersionConfig.xcconfig
sed -i '' "s/^MARKETING_VERSION = .*$/MARKETING_VERSION = $version/" $sdkversionconfig_file

echo "Bump SDK version from $current_version to $version."

Expand Down
Loading