2022-05-30 17:10:44 +00:00
|
|
|
import { Factory } from 'ember-cli-mirage';
|
|
|
|
import faker from 'nomad-ui/mirage/faker';
|
2022-07-22 20:05:35 +00:00
|
|
|
|
2022-05-30 17:10:44 +00:00
|
|
|
export default Factory.extend({
|
|
|
|
id: () => faker.random.words(3).split(' ').join('/').toLowerCase(),
|
|
|
|
path() {
|
|
|
|
return this.id;
|
|
|
|
},
|
2022-07-08 14:08:02 +00:00
|
|
|
namespace: null,
|
2022-06-20 16:48:38 +00:00
|
|
|
createdIndex: 100,
|
|
|
|
modifiedIndex: 100,
|
2022-08-03 16:42:50 +00:00
|
|
|
createTime: () => faker.date.past(15) * 1000000,
|
|
|
|
modifyTime: () => faker.date.recent(1) * 1000000,
|
2022-05-30 17:10:44 +00:00
|
|
|
items() {
|
|
|
|
return (
|
|
|
|
this.Items || {
|
|
|
|
[faker.database.column()]: faker.database.collation(),
|
|
|
|
[faker.database.column()]: faker.database.collation(),
|
|
|
|
[faker.database.column()]: faker.database.collation(),
|
|
|
|
[faker.database.column()]: faker.database.collation(),
|
|
|
|
[faker.database.column()]: faker.database.collation(),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
2022-07-08 14:08:02 +00:00
|
|
|
|
|
|
|
afterCreate(variable, server) {
|
|
|
|
if (!variable.namespaceId) {
|
|
|
|
const namespace =
|
|
|
|
(server.db.jobs && server.db.jobs[0]?.namespace) || 'default';
|
|
|
|
variable.update({
|
|
|
|
namespace,
|
|
|
|
});
|
2022-07-22 20:05:35 +00:00
|
|
|
} else {
|
|
|
|
variable.update({
|
|
|
|
namespace: variable.namespaceId,
|
|
|
|
});
|
2022-07-08 14:08:02 +00:00
|
|
|
}
|
|
|
|
},
|
2022-05-30 17:10:44 +00:00
|
|
|
});
|