Skip to content

Commit

Permalink
contribution parsing fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
87kangsw committed Jul 23, 2023
1 parent c2b1599 commit 28c0226
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
28 changes: 12 additions & 16 deletions GitTime/Sources/ViewControllers/Activity/ActivityViewReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,25 +263,21 @@ final class ActivityViewReactor: ReactorKit.Reactor {
var profileURL: String = ""

if let doc = try? HTML(html: response.data, encoding: .utf8) {
if let calendar = doc.css("div.js-calendar-graph").first {
for weekdayRow in calendar.css("tbody tr") {
for rect in weekdayRow.css("td.ContributionCalendar-day") {

if var date = rect["data-date"],
let dataLevel = rect["data-level"] {

date = date.replacingOccurrences(of: "\\", with: "")
.replacingOccurrences(of: "/", with: "")
.replacingOccurrences(of: "\"", with: "")

let colorType = ContributionHexColorTypes.allCases.first { $0.rawValue == Int(dataLevel) }
if let hexString = colorType?.hexString {
contributions.append(Contribution(date: date, contribution: Int(dataLevel)!, hexColor: hexString))
}
}
for rect in doc.css("td") {
if var date = rect["data-date"],
let dataLevel = rect["data-level"] {

date = date.replacingOccurrences(of: "\\", with: "")
.replacingOccurrences(of: "/", with: "")
.replacingOccurrences(of: "\"", with: "")

let colorType = ContributionHexColorTypes.allCases.first { $0.rawValue == Int(dataLevel) }
if let hexString = colorType?.hexString {
contributions.append(Contribution(date: date, contribution: Int(dataLevel)!, hexColor: hexString))
}
}
}


for count in doc.css("h2, f4 text-normal mb-2") {
let decimalCharacters = CharacterSet.decimalDigits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ final class BuddyViewReactor: Reactor {
var profileURL: String = ""

if let doc = try? HTML(html: response.data, encoding: .utf8) {
for rect in doc.css("rect") {
for rect in doc.css("td") {
if var date = rect["data-date"],
let dataLevel = rect["data-level"] {

Expand Down

0 comments on commit 28c0226

Please sign in to comment.