Skip to content

Conversation

@astansler
Copy link
Member

No description provided.

@astansler astansler self-assigned this Sep 13, 2017
Copy link
Contributor

@asurkov asurkov left a comment

Choose a reason for hiding this comment

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

looks good! r=me

+ commit.raw?.shortMessage)
commit.repo = repo
commit
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I miss why you cant' move commit.repo setting into .doOnNext, but actually not sure why you do commit.repo setting at all, I don't see where it's used

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved. Commit belong to repo. Used to retrieve repo rehash.

factDayTime[dateTime.hour] += 1
factsDayWeek[author] = factDayWeek
factsDayTime[author] = factDayTime
}, Observable.just(Commit()))
Copy link
Contributor

Choose a reason for hiding this comment

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

not part of this changeset, but just curious why do you need to attach a fake Commit() into the end?

Copy link
Member Author

Choose a reason for hiding this comment

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

Commits are combined in pairs, an empty commit concatenated to calculate the diff of the initial commit.


// Commits are combined in pairs, an empty commit concatenated to
// calculate the diff of the initial commit.
Observable.concat(getObservableCommits(), Observable.just(Commit()))
Copy link
Contributor

Choose a reason for hiding this comment

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

btw, not introduced by this changeset, so feel free to ignore it, but I would probably rename getObservableCommits() to commitsAsObservable() or something, getObservableCommits name is misleading, it makes me think that you want some sort of observable commits only, i.e. there are some not observable commits that we want to ignore.

Copy link
Member Author

Choose a reason for hiding this comment

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

getCommitsAsObservable(), ok.

.doOnNext { commit ->
val author = commit.author
val factDayWeek = factsDayWeek[author] ?: Array(7) { 0 }
val factDayTime = factsDayTime[author] ?: Array(24) { 0 }
Copy link
Contributor

Choose a reason for hiding this comment

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

getOrPut should be nicer here

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't fit it in one line, the same logic inside, I'll leave it as is.

postCommitsToServer(commitsBundle)
}, { e ->
Logger.error("Error while hashing: $e")
}, {
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth adding a comment that this is onComplete part

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

testRepo.createFile("test1.txt", listOf("line1", "line2"))
testRepo.commit(message = "initial commit",
author = author1,
date = createDate(month = 1, day = 1, // Sunday.
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth to point year explicitly, if createDate() gets changed for some reason, then a failing test might take by surprise

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

val knownCommits = repo.commits.toHashSet()

val factsDayWeek = hashMapOf<Author, Array<Int>>()
val factsDayTime = hashMapOf<Author, Array<Int>>()
Copy link
Contributor

Choose a reason for hiding this comment

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

btw, what's difference between hashMapOf and mutableMap?

Copy link
Member Author

@astansler astansler Sep 14, 2017

Choose a reason for hiding this comment

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

MutableMap is an interface and mutableMapOf create default implementation of map, which is for kotlin 1.1.4-2 LinkedHashMap.
hashMapOf and linkedMapOf clearly create HashMap and LinkedHashMap which implement MutableMap interface.

if (count > 0) {
facts.add(Fact(repo, FACT_KEY_COMMITS_DAYTIME +
hour, count.toDouble(), author))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

curious, if FACT_KEY_BLABLA_NUMBER can be sent to the server in a form to avoid strings parsing (regexps?), for example, if there's a way to serialize a list so that the server may deserialize it by some standard API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Me too.

private val git: Git) {
companion object {
val FACT_KEY_COMMITS_DAYWEEK = "commits-dayweek-"
val FACT_KEY_COMMITS_DAYTIME = "commits-daytime-"
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to put these into some namespace? it be nice to have something like FactKey.CommitDayWeek

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

@astansler astansler merged commit d220179 into master Sep 14, 2017
@astansler astansler deleted the dev-fun-fact branch September 14, 2017 11:20
astansler added a commit that referenced this pull request Sep 14, 2017
* feat: add day of week and time of day fun facts (APP-49, APP-61)

* wip: add account of time zones, switch to long type for timestamp

* feat: test for date facts, add date to commit in TestRepo

* fix: add FactKey for all key names, fix PR requests

* chore: add year to test
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