Skip to content

Commit

Permalink
Merge pull request #22 from RishabhTayal/login-fix
Browse files Browse the repository at this point in the history
added processing build data
  • Loading branch information
RishabhTayal committed Dec 27, 2017
2 parents e832ed4 + d335e3b commit 828d91c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AppDetailViewController: UIViewController {
enum RowType: Int {
case testers
case reviews
case processingBuilds
case count

var description: String {
Expand All @@ -21,6 +22,8 @@ class AppDetailViewController: UIViewController {
return "Testers"
case .reviews:
return "Reviews"
case .processingBuilds:
return "Processing Builds"
default:
return ""
}
Expand All @@ -29,6 +32,7 @@ class AppDetailViewController: UIViewController {

var tableView: UITableView!
var app: App?
var processingBuildCount = 0

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -38,6 +42,19 @@ class AppDetailViewController: UIViewController {
tableView.delegate = self
tableView.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleWidth.rawValue) | UInt8(UIViewAutoresizing.flexibleHeight.rawValue)))
view.addSubview(tableView)

getProcessingBuilds()
}

func getProcessingBuilds() {
ServiceCaller.getProcessingBuilds(bundleId: (app?.bundleId)!) { result, e in
DispatchQueue.main.async {
if let r = result as? [[String: Any]] {
self.processingBuildCount = r.count
self.tableView.reloadData()
}
}
}
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -59,7 +76,12 @@ extension AppDetailViewController: UITableViewDataSource, UITableViewDelegate {
cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
cell?.accessoryType = .disclosureIndicator
}
cell?.textLabel?.text = RowType(rawValue: indexPath.row)?.description
let rowType = RowType(rawValue: indexPath.row)!
if rowType == .processingBuilds {
cell?.textLabel?.text = String(processingBuildCount) + " builds processing"
} else {
cell?.textLabel?.text = rowType.description
}
return cell!
}

Expand All @@ -74,6 +96,7 @@ extension AppDetailViewController: UITableViewDataSource, UITableViewDelegate {
reviewVC.app = app
navigationController?.pushViewController(reviewVC, animated: true)
default:
tableView.deselectRow(at: indexPath, animated: true)
break
}
}
Expand Down
16 changes: 14 additions & 2 deletions ReviewMonitor/ServiceCaller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ import UIKit

class ServiceCaller: NSObject {

private static let BaseURL = "https://review-monitor.herokuapp.com/"
private static let BaseUrl: String = {
#if DEBUG
return "http://127.0.0.1:4567/"
#else
return "https://review-monitor.herokuapp.com/"
#endif
}()

private enum EndPoint: String {
case login = "login/v2"
case apps
case ratings
case response
case testers
case processing_builds
}

private enum HTTPMethod: String {
Expand Down Expand Up @@ -57,9 +64,14 @@ class ServiceCaller: NSObject {
makeAPICall(endPoint: .testers, params: params, completionBlock: completion)
}

class func getProcessingBuilds(bundleId: String, completion: CompletionBlock?) {
let params = ["bundle_id": bundleId]
makeAPICall(endPoint: .processing_builds, params: params, completionBlock: completion)
}

private class func makeAPICall(endPoint: EndPoint, params: [String: Any] = [:], httpMethod: HTTPMethod = .GET, completionBlock: CompletionBlock?) {
var params = params
var url = BaseURL + endPoint.rawValue
var url = BaseUrl + endPoint.rawValue
if let account = AccountManger.getCurrentAccount() {
params.updateValue(account.username, forKey: "username")
params["password"] = account.password
Expand Down
2 changes: 1 addition & 1 deletion ReviewMonitor/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<key>CFBundleVersion</key>
<string>255</string>
<string>263</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down

0 comments on commit 828d91c

Please sign in to comment.