-
Notifications
You must be signed in to change notification settings - Fork 26
public Initializes of ACData
#6
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
Conversation
let datas = date.datesInWeek.map { date -> ACData in | ||
let data = ACData(date: date, count: getDateCount(sourceDates: sourceDates, date: date)) | ||
return data | ||
if let data = sourceDates[date] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change brings this bug #14 in. The date
of sourceDates[date]
doesn't necessarily need to be the start moment of the day. Therefore, sourceDates[date]
is nil
when toDate
is Date()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry my bad
- the dictionary was introduced because I had performance concerns.
- you need to use Date().startOfDay as a key to archive the count for that day
I made a mistake. this pr I didn't want to introduce these changes
only
-init(date: Date, count: Int = 0) {
+public init(date: Date, count: Int = 0) {
self.date = date
self.count = count
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@racechao That's ok, I've created a PR #13 to fix these issues.
- We can turn the
[Date]
into a[Date:ACData]
internally with only 1 literation (O(n)
) by doing so 3270273#diff-6eace7fd00e64a79f64bb279676278b16eab8ec0f93e83fa4d8f5a422ffd040b, I think the performance should be acceptable. The difference is whether we need to request users to make the conversion by themselves. And we'd better not to break the API policy for backward compatibility. Or, we can create a newinit
to support[Data:ACData]
type parameter as thesourceDatas
in the next new versions of this library. - Yeah the
date
keys have been turned intostartOfDay
during the process mentioned in the 1st point.
FYI @jasudev for more context.
Uh oh!
There was an error while loading. Please reload this page.