Skip to content

Commit

Permalink
ランキング用の保存処理を削除
Browse files Browse the repository at this point in the history
parse側でaftersaveでトリガー作ったのでアプリ側からは不要になったので
  • Loading branch information
anzfactory committed Jun 13, 2015
1 parent 9731ea3 commit f00af8c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 40 deletions.
8 changes: 2 additions & 6 deletions QiitaCollection/AnonymousAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,8 @@ class AnonymousAccount: NSObject {
})
}

func saveHistory(entry: EntryEntity, isRanking: Bool) {
if isRanking {
ParseManager.sharedInstance.putRankingHistory(entry)
} else {
ParseManager.sharedInstance.putHistory(entry)
}
func saveHistory(entry: EntryEntity) {
ParseManager.sharedInstance.putHistory(entry)
}

func histories(page:Int, completion:(items: [HistoryEntity]) -> Void) {
Expand Down
7 changes: 1 addition & 6 deletions QiitaCollection/EntryDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EntryDetailViewController: BaseViewController, NSUserActivityDelegate {
}
didSet {
if let entry = self.displayEntry {
self.account.saveHistory(entry, isRanking: false)
self.account.saveHistory(entry)
}
}
}
Expand Down Expand Up @@ -73,11 +73,6 @@ class EntryDetailViewController: BaseViewController, NSUserActivityDelegate {
if let activity = self.senderActivity {
activity.invalidate()
}
if self.isMovingFromParentViewController() || self.isBeingDismissed() {
if let entry = self.displayEntry {
self.account.saveHistory(entry, isRanking: true)
}
}
super.viewWillDisappear(animated)
}

Expand Down
28 changes: 0 additions & 28 deletions QiitaCollection/ParseManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,6 @@ class ParseManager {
}
}

func putRankingHistory(entry: EntryEntity) {

var data: PFObject = PFObject(className: "RankingHistory")

let query: PFQuery = PFQuery(className: "RankingHistory")
query.whereKey("entryId", equalTo: entry.id)
query.getFirstObjectInBackgroundWithBlock { (resultData, error) -> Void in
if let e = error {
// 101 は notresult のエラー (該当なし)
if e.code != 101 {
return
}
data["entryId"] = entry.id
} else {
data = resultData!
}

data["title"] = entry.title
data["tags"] = TagEntity.titles(entry.tags)
data.incrementKey("count")

data.saveInBackgroundWithBlock({ (successed, error) -> Void in
// 履歴なので失敗しようが成功しようが関知しない
})

}
}

func getHistory(page: Int, completion: (items: [HistoryEntity]) -> Void) {

if !self.isAuthorized() {
Expand Down

0 comments on commit f00af8c

Please sign in to comment.