Skip to content

Commit da3a48e

Browse files
committed
mirage/crate: Calculate newest_version property
1 parent e1adf65 commit da3a48e

File tree

5 files changed

+6
-26
lines changed

5 files changed

+6
-26
lines changed

mirage/factories/crate.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export default Factory.extend({
1616
documentation: null,
1717
homepage: null,
1818
repository: null,
19-
newest_version: '1.0.0',
2019

2120
created_at: '2010-06-16T21:30:45Z',
2221
updated_at: '2017-02-24T12:34:56Z',

mirage/fixtures/crates.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export default [
1616
homepage: 'https://icorderi.github.io/icorderi/kinetic-rust',
1717
id: 'kinetic-rust',
1818
keywordIds: [],
19-
newest_version: '0.0.16',
2019
name: 'kinetic-rust',
2120
repository: 'https://github.com/icorderi/kinetic-rust/',
2221
updated_at: '2015-04-21T00:15:49Z',
@@ -40,7 +39,6 @@ export default [
4039
homepage: 'https://github.com/thehydroimpulse/nanomsg.rs',
4140
id: 'nanomsg',
4241
keywordIds: ['network'],
43-
newest_version: '0.6.1',
4442
name: 'nanomsg',
4543
repository: 'https://github.com/thehydroimpulse/nanomsg.rs',
4644
updated_at: '2016-12-28T08:40:00Z',
@@ -69,7 +67,6 @@ export default [
6967
homepage: 'https://github.com/huonw/external_mixin',
7068
id: 'rust_mixin',
7169
keywordIds: ['rust', 'plugin', 'code-generation'],
72-
newest_version: '0.0.1',
7370
name: 'rust_mixin',
7471
repository: 'https://github.com/huonw/external_mixin',
7572
updated_at: '2015-02-27T11:52:13Z',
@@ -141,7 +138,6 @@ export default [
141138
homepage: 'https://github.com/huonw/external_mixin',
142139
id: 'external_mixin',
143140
keywordIds: ['python', 'ruby', 'shell', 'plugin', 'code-generation'],
144-
newest_version: '0.0.1',
145141
name: 'external_mixin',
146142
repository: 'https://github.com/huonw/external_mixin',
147143
updated_at: '2015-02-27T11:51:58Z',
@@ -156,7 +152,6 @@ export default [
156152
homepage: 'https://github.com/huonw/external_mixin',
157153
id: 'external_mixin_umbrella',
158154
keywordIds: ['plugin', 'code-generation'],
159-
newest_version: '0.0.2',
160155
name: 'external_mixin_umbrella',
161156
repository: 'https://github.com/huonw/external_mixin',
162157
updated_at: '2015-02-27T11:52:30Z',
@@ -172,7 +167,6 @@ export default [
172167
homepage: 'https://github.com/whatisinternet/inflector',
173168
id: 'Inflector',
174169
keywordIds: ['string', 'case', 'camel', 'snake', 'inflection'],
175-
newest_version: '0.1.6',
176170
name: 'Inflector',
177171
repository: 'https://github.com/whatisinternet/inflector',
178172
updated_at: '2015-10-27T01:51:42Z',
@@ -187,7 +181,6 @@ export default [
187181
homepage: null,
188182
id: 'rs-es',
189183
keywordIds: ['elasticsearch', 'elastic'],
190-
newest_version: '0.1.17',
191184
name: 'rs-es',
192185
repository: 'https://github.com/benashford/rs-es',
193186
updated_at: '2015-09-09T15:34:50Z',
@@ -202,7 +195,6 @@ export default [
202195
homepage: 'https://github.com/DaGenix/rust-crypto/',
203196
id: 'rust-crypto',
204197
keywordIds: [],
205-
newest_version: '0.2.34',
206198
name: 'rust-crypto',
207199
repository: 'https://github.com/DaGenix/rust-crypto/',
208200
updated_at: '2015-10-29T01:16:17Z',
@@ -217,7 +209,6 @@ export default [
217209
homepage: null,
218210
id: 'rust-htslib',
219211
keywordIds: [],
220-
newest_version: '0.5.2',
221212
name: 'rust-htslib',
222213
repository: 'https://github.com/rust-bio/rust-htslib.git',
223214
updated_at: '2015-11-11T00:10:43Z',
@@ -232,7 +223,6 @@ export default [
232223
homepage: 'https://github.com/rustless/rustless',
233224
id: 'rustless',
234225
keywordIds: [],
235-
newest_version: '0.8.0',
236226
name: 'rustless',
237227
repository: 'https://crates.io/crates/rustless',
238228
updated_at: '2015-10-31T11:49:29Z',
@@ -247,7 +237,6 @@ export default [
247237
homepage: null,
248238
id: 'serde',
249239
keywordIds: [],
250-
newest_version: '0.6.1',
251240
name: 'serde',
252241
repository: 'https://github.com/serde-rs/serde',
253242
updated_at: '2015-10-18T03:10:21Z',
@@ -262,7 +251,6 @@ export default [
262251
homepage: 'https://github.com/livioribeiro/rusted-cypher',
263252
id: 'rusted_cypher',
264253
keywordIds: [],
265-
newest_version: '0.7.1',
266254
name: 'rusted_cypher',
267255
repository: 'https://github.com/livioribeiro/rusted-cypher',
268256
updated_at: '2015-11-07T17:26:55Z',
@@ -278,7 +266,6 @@ export default [
278266
homepage: null,
279267
id: 'zlib',
280268
keywordIds: [],
281-
newest_version: '0.0.1',
282269
name: 'zlib',
283270
repository: null,
284271
updated_at: '2015-01-02T20:54:04Z',
@@ -294,7 +281,6 @@ export default [
294281
homepage: null,
295282
id: 'rustful',
296283
keywordIds: [],
297-
newest_version: '0.5.0',
298284
name: 'rustful',
299285
repository: 'https://github.com/Ogeon/rustful',
300286
updated_at: '2015-09-19T21:10:27Z',
@@ -309,7 +295,6 @@ export default [
309295
homepage: null,
310296
id: 'postgres',
311297
keywordIds: [],
312-
newest_version: '0.10.1',
313298
name: 'postgres',
314299
repository: 'https://github.com/sfackler/rust-postgres',
315300
updated_at: '2015-11-08T00:48:59Z',
@@ -324,7 +309,6 @@ export default [
324309
homepage: 'https://github.com/BurntSushi/quickcheck',
325310
id: 'quickcheck',
326311
keywordIds: [],
327-
newest_version: '0.2.24',
328312
name: 'quickcheck',
329313
repository: 'https://github.com/BurntSushi/quickcheck',
330314
updated_at: '2015-09-20T21:53:38Z',
@@ -339,7 +323,6 @@ export default [
339323
homepage: 'https://github.com/BurntSushi/quickcheck',
340324
id: 'quickcheck_macros',
341325
keywordIds: [],
342-
newest_version: '0.2.24',
343326
name: 'quickcheck_macros',
344327
repository: 'https://github.com/BurntSushi/quickcheck',
345328
updated_at: '2015-09-20T21:53:57Z',
@@ -355,7 +338,6 @@ export default [
355338
homepage: 'https://github.com/nicolas-cherel/rustlex',
356339
id: 'unicorn-rpc',
357340
keywordIds: [],
358-
newest_version: '0.3.1',
359341
name: 'unicorn-rpc',
360342
repository: 'https://github.com/nicolas-cherel/rustlex',
361343
updated_at: '2015-08-25T19:15:35Z',
@@ -370,7 +352,6 @@ export default [
370352
homepage: null,
371353
id: 'nom',
372354
keywordIds: [],
373-
newest_version: '1.0.1',
374355
name: 'nom',
375356
repository: 'https://github.com/Geal/nom',
376357
updated_at: '2015-11-22T22:00:41Z',
@@ -379,28 +360,24 @@ export default [
379360
{
380361
id: 'libc',
381362
name: 'libc',
382-
newest_version: '1.0.1',
383363
downloads: 5169,
384364
recent_downloads: 69,
385365
},
386366
{
387367
id: 'nanomsg-sys',
388368
name: 'nanomsg-sys',
389-
newest_version: '1.0.1',
390369
downloads: 5169,
391370
recent_downloads: 69,
392371
},
393372
{
394373
id: 'mock-build-deps',
395374
name: 'mock-build-deps',
396-
newest_version: '1.0.1',
397375
downloads: 5169,
398376
recent_downloads: 69,
399377
},
400378
{
401379
id: 'mock-dev-deps',
402380
name: 'mock-dev-deps',
403-
newest_version: '1.0.1',
404381
downloads: 5169,
405382
recent_downloads: 69,
406383
},

mirage/serializers/crate.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { assert } from '@ember/debug';
22
import semverSort from 'semver/functions/rsort';
33
import BaseSerializer from './application';
4+
import { compareIsoDates } from '../route-handlers/-utils';
45

56
export default BaseSerializer.extend({
67
attrs: [
@@ -54,6 +55,9 @@ export default BaseSerializer.extend({
5455
semverSort(versionNums);
5556
hash.max_version = versionNums[0];
5657

58+
let newestVersions = versions.sort((a, b) => compareIsoDates(b.updated_at, a.updated_at));
59+
hash.newest_version = newestVersions.models[0].num;
60+
5761
hash.categories = hash.category_ids;
5862
delete hash.category_ids;
5963

tests/acceptance/front-page-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module('Acceptance | front page', function(hooks) {
3535
assert.dom('[data-test-total-downloads]').hasText('143,345');
3636
assert.dom('[data-test-total-crates]').hasText('23');
3737

38-
assert.dom('[data-test-new-crates] [data-test-crate-link="0"]').hasText('Inflector (0.1.6)');
38+
assert.dom('[data-test-new-crates] [data-test-crate-link="0"]').hasText('Inflector (1.0.0)');
3939
assert.dom('[data-test-new-crates] [data-test-crate-link="0"]').hasAttribute('href', '/crates/Inflector');
4040

4141
assert.dom('[data-test-most-downloaded] [data-test-crate-link="0"]').hasText('serde');

tests/mirage/summary-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module('Mirage | Summary', function(hooks) {
8383
},
8484
max_version: '1.0.4',
8585
name: 'crate-4',
86-
newest_version: '1.0.0',
86+
newest_version: '1.0.4',
8787
repository: null,
8888
updated_at: '2017-02-24T12:34:56Z',
8989
versions: null,

0 commit comments

Comments
 (0)