Skip to content

Conversation

alfredcc
Copy link
Contributor

@alfredcc alfredcc commented Apr 6, 2023

image

@alfredcc alfredcc changed the title public Initializes ACData public Initializes of ACData Apr 6, 2023
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] {
Copy link

@Maples7 Maples7 Apr 2, 2024

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().

Copy link

@racechao racechao Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry my bad

  1. the dictionary was introduced because I had performance concerns.
  2. 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
    }

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@Maples7 Maples7 Apr 3, 2024

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.

  1. 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 new init to support [Data:ACData] type parameter as the sourceDatas in the next new versions of this library.
  2. Yeah the date keys have been turned into startOfDay during the process mentioned in the 1st point.

FYI @jasudev for more context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants