This repository was archived by the owner on Aug 31, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 11import moment from 'moment' ;
22import casual from 'casual' ;
3+ import createUniqueKey from '../src/utils/uniqueKey_generator' ;
34
45const DEFAULT_SIZE = 100 ;
56
67export const mockIndices = new Array ( 1 ) . fill ( ) . map ( ( ) => moment ( ) . format ( 'YYYY-MM' ) ) ;
78
89export const mockControllers = new Array ( DEFAULT_SIZE ) . fill ( ) . map ( ( value , index ) => ( {
910 controller : `${ casual . word } .${ casual . word } .com` ,
10- key : casual . ip ,
11+ key : createUniqueKey ( ) ,
1112 last_modified_string : moment ( ) . valueOf ( moment . utc ( ) ) ,
1213 last_modified_value : moment . utc ( ) + index ,
1314 results : casual . integer ( 1 , DEFAULT_SIZE ) ,
1415} ) ) ;
1516
1617export const mockResults = hostname =>
17- new Array ( DEFAULT_SIZE ) . fill ( ) . map ( ( ) => ( {
18+ new Array ( DEFAULT_SIZE ) . fill ( ) . map ( ( value , index ) => ( {
1819 '@metadata.controller_dir' : hostname ,
1920 config : casual . word ,
2021 controller : hostname ,
2122 end : moment . utc ( ) ,
2223 // Since dataset id is a long hex string, removed "-" characters here to make it look like real data
2324 id : casual . uuid . replace ( / - / g, '' ) ,
24- result : casual . word ,
25+ result : ` ${ index } ${ hostname . slice ( 0 , - 6 ) } ${ index } ` ,
2526 start : moment . utc ( ) ,
2627 } ) ) ;
2728
Original file line number Diff line number Diff line change 1+ export default function createUniqueKey ( ) {
2+ const dt = new Date ( ) . getTime ( ) ;
3+ const tempStr = 'xxxxxx.yxyxxyxy.xxxyyy' ;
4+ // eslint-disable-next-line func-names
5+ const uuid = tempStr . replace ( / [ x y ] / g, function ( c ) {
6+ /* eslint no-bitwise: ["error", { "int32Hint": true }] */
7+ const r = ( ( dt + Math . random ( ) * 16 ) & 0xf ) | 0 ;
8+ /* eslint no-bitwise: ["error", { "allow": ["&", "|"] }] */
9+ return ( c === 'x' ? r : ( r & 0x3 ) | 0x8 ) . toString ( 16 ) ;
10+ } ) ;
11+ return uuid ;
12+ }
You can’t perform that action at this time.
0 commit comments