-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[cocoapods] fix Metric regexes #1713
Conversation
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.
I do see one potential issue with the revised regexes: "numbers" with leading zeros will now be valid, for instance 000002/week
would pass, which is a bit strange. Maybe something along the lines of (0|[1-9][0-9]*)
would do the trick?
good call - cheers |
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.
Changes look good 👍
services/test-validators.js
Outdated
@@ -50,11 +50,11 @@ const isPhpVersionReduction = withRegex(/^((>= \d+(\.\d+)?)|(\d+\.\d+(, \d+\.\d+ | |||
const isStarRating = withRegex(/^(?=.{5}$)(\u2605{0,5}[\u00BC\u00BD\u00BE]?\u2606{0,5})$/); | |||
|
|||
// Required to be > 0, because accepting zero masks many problems. |
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.
Could you update this comment too.
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.
Hmm.. Now you've pointed out this comment, I've gone and looked back at the history. I probably should have done this before submitting this PR:
It looks like this was introduced in response to a particular problem, where an error condition was manifesting as a zero value: #1201
That seems like a bit of an edge case, but I now wonder if there are other cases like this I'm not thinking of 🤔
So maybe would be better to leave the regexes requiring a non-zero value and just switch this test to a more active repo. Then I tried to find one and realised that while the badge is correctly reporting the number from the CocoaPods API, CocoaPods seems to be incorrectly reporting all (or many) packages as having zero downloads per week. For example, this is one of the most popular packages on cocoapods: http://cocoapods.org/pods/Alamofire its unlikely that this has really had >300,000 downloads this month with 0 of them in the last week. This seems to be a reported issue which has been open for some time :/
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.
@chris48s good investigation. #1201 was a really ugly bug.
@RedSparr0w 0
is OK for me, better than unavailable
. Stats are available and are equal 0
.
In my opinion this kind of bugs can be avoided when we have tests which stubs and verifies exact value.
What do you think about replacing tests for weekly downloads and weekly apps with?
t.create('downloads (valid, weekly)')
.get('/dw/AFNetworking.json')
.intercept(nock => nock('https://metrics.cocoapods.org')
.get('/api/v1/pods/AFNetworking')
.reply(200, { stats: { download_week: 2 }}))
.expectJSON({
name: 'downloads',
value: '2/week'
});
t.create('apps (valid, weekly)')
.get('/aw/AFNetworking.json')
.intercept(nock => nock('https://metrics.cocoapods.org')
.get('/api/v1/pods/AFNetworking')
.reply(200, { stats: { app_week: 2 }}))
.expectJSON({
name: 'apps',
value: '2/week'
});
e9439af
to
9cb5978
Compare
Having chewed this over a bit, I think the best solution here is to:
|
It appears this does not only happen on the weekly stats. refs badges#1713
It appears this does not only happen on the weekly stats. refs #1713
There are a couple of
cocoapods
tests failing because the package we are testing against has been getting 0 downloads/week (how sad 😞 ) and theisMetricOverTimePeriod
regex didn't allow0/week
. In principle though, it should also be valid to have 0 open issues + so on, so I've changed the others