Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
import {array, fragment, fragmentArray} from 'ember-data-model-fragments/attributes';
export default Model.extend({
changeTracker: {trackHasMany: true, auto: true, enableIsDirty: true},
name: attr('string'),
style: attr('string'),
// object type
info: attr('object'),
blob: attr('json'),
// fragments
list: array('number'),
location: fragment('location'),
things: fragmentArray('things'),
// associations
company: belongsTo('company', { async: true, polymorphic: true }),
profile: belongsTo('profile', { async: false }),
projects: hasMany('project', { async: true }),
pets: hasMany('pet', { async: false, polymorphic: true })
});
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
import {array, fragment, fragmentArray} from 'ember-data-model-fragments/attributes';
export default Model.extend({
changeTracker: {trackHasMany: true, auto: true, enableIsDirty: true},
name: attr('string'),
style: attr('string'),
// object type
info: attr('object'),
blob: attr('json'),
// fragments
list: array('number'),
location: fragment('location'),
things: fragmentArray('things'),
// associations
company: belongsTo('company', { async: true, polymorphic: true }),
profile: belongsTo('profile', { async: false }),
projects: hasMany('project', { async: true }),
pets: hasMany('pet', { async: false, polymorphic: true })
});
import { alias } from "@ember/object/computed";
import { get, computed } from "@ember/object";
import attr from "ember-data/attr";
import Model from "ember-data/model";
import { belongsTo } from "ember-data/relationships";
import { fragment } from "ember-data-model-fragments/attributes";
import Moment from "moment";
export default Model.extend({
/** type {TwitchTicketProduct} */
product: fragment( "twitch-ticket-product", { defaultValue: {} } ),
/** type {TwitchTicketPurchaseProfile} */
purchase_profile: fragment( "twitch-ticket-purchase-profile", { defaultValue: {} } ),
/** @type ComputedProperty> */
partner_login: belongsTo( "twitch-user", { async: true } ),
access_end: attr( "date" ),
access_start: attr( "date" ),
expired: attr( "boolean" ),
is_gift: attr( "boolean" ),
/** @type ComputedProperty> */
channel: alias( "partner_login.channel" ),
// load the chained PromiseProxy
async loadChannel() {
const user = this.partner_login;
nodeClass: attr('string'),
isDraining: attr('boolean'),
schedulingEligibility: attr('string'),
status: attr('string'),
statusDescription: attr('string'),
shortId: shortUUIDProperty('id'),
modifyIndex: attr('number'),
// Available from single response
httpAddr: attr('string'),
tlsEnabled: attr('boolean'),
attributes: fragment('node-attributes'),
meta: fragment('node-attributes'),
resources: fragment('resources'),
reserved: fragment('resources'),
drainStrategy: fragment('drain-strategy'),
isEligible: equal('schedulingEligibility', 'eligible'),
address: computed('httpAddr', function() {
return ipParts(this.httpAddr).address;
}),
port: computed('httpAddr', function() {
return ipParts(this.httpAddr).port;
}),
isPartial: computed('httpAddr', function() {
return this.httpAddr == null;
}),
allocations: hasMany('allocations', { inverse: 'node' }),
name: attr('string'),
datacenter: attr('string'),
nodeClass: attr('string'),
isDraining: attr('boolean'),
schedulingEligibility: attr('string'),
status: attr('string'),
statusDescription: attr('string'),
shortId: shortUUIDProperty('id'),
modifyIndex: attr('number'),
// Available from single response
httpAddr: attr('string'),
tlsEnabled: attr('boolean'),
attributes: fragment('node-attributes'),
meta: fragment('node-attributes'),
resources: fragment('resources'),
reserved: fragment('resources'),
drainStrategy: fragment('drain-strategy'),
isEligible: equal('schedulingEligibility', 'eligible'),
address: computed('httpAddr', function() {
return ipParts(this.httpAddr).address;
}),
port: computed('httpAddr', function() {
return ipParts(this.httpAddr).port;
}),
isPartial: computed('httpAddr', function() {
return this.httpAddr == null;
}),
// unique, non-empty values, alpha sort
return [...new Set(sources)].filter(Boolean).sort();
}
};
export default class ServiceInstance extends Model {
@attr('string') uid;
@attr('string') Datacenter;
// ProxyInstance is the ember-data model relationship
@belongsTo('Proxy') ProxyInstance;
// Proxy is the actual JSON api response
@attr() Proxy;
@attr() Node;
@attr() Service;
@fragmentArray('health-check') Checks;
@attr('number') SyncTime;
@attr() meta;
@attr({ defaultValue: () => [] }) Resources; // []
// The name is the Name of the Service (the grouping of instances)
@alias('Service.Service') Name;
// If the ID is blank fallback to the Service.Service (the Name)
@or('Service.{ID,Service}') ID;
@or('Service.Address', 'Node.Service') Address;
@attr('string') SocketPath;
@alias('Service.Tags') Tags;
@alias('Service.Meta') Meta;
@alias('Service.Namespace') Namespace;
migratingAllocations: computed('allocations.@each.{isMigrating,isRunning}', function() {
return this.allocations.filter(alloc => alloc.isRunning && alloc.isMigrating);
}),
lastMigrateTime: computed('allocations.@each.{isMigrating,isRunning,modifyTime}', function() {
const allocation = this.allocations
.filterBy('isRunning', false)
.filterBy('isMigrating')
.sortBy('modifyTime')
.reverse()[0];
if (allocation) {
return allocation.modifyTime;
}
}),
drivers: fragmentArray('node-driver'),
events: fragmentArray('node-event'),
hostVolumes: fragmentArray('host-volume'),
detectedDrivers: computed('drivers.@each.detected', function() {
return this.drivers.filterBy('detected');
}),
unhealthyDrivers: computed('detectedDrivers.@each.healthy', function() {
return this.detectedDrivers.filterBy('healthy', false);
}),
unhealthyDriverNames: computed('unhealthyDrivers.@each.name', function() {
return this.unhealthyDrivers.mapBy('name');
}),
// A status attribute that includes states not included in node status.
// Useful for coloring and sorting nodes
// polls description
description: attr('string', {
defaultValue: ''
}),
// ISO 8601 date + time string in UTC
expirationDate: attr('string', {
includePlainOnCreate: 'serverExpirationDate'
}),
// Must all options been answered?
forceAnswer: attr('boolean'),
// array of polls options
options: fragmentArray('option'),
// FindADate or MakeAPoll
pollType: attr('string'),
// timezone poll got created in (like "Europe/Berlin")
timezone: attr('string'),
// polls title
title: attr('string'),
// Croodle version poll got created with
version: attr('string', {
encrypted: false
}),
/*
// If any task group is not promoted yet requires promotion and the deployment
// is still running, the deployment needs promotion.
requiresPromotion: computed('taskGroupSummaries.@each.promoted', function() {
return this.status === 'running' &&
this.taskGroupSummaries
.toArray()
.some(summary => summary.get('requiresPromotion') && !summary.get('promoted'));
}),
status: attr('string'),
statusDescription: attr('string'),
isRunning: equal('status', 'running'),
taskGroupSummaries: fragmentArray('task-group-deployment-summary'),
allocations: hasMany('allocations'),
version: computed('versionNumber', 'job.versions.content.@each.number', function() {
return (this.get('job.versions') || []).findBy('number', this.versionNumber);
}),
// Dependent keys can only go one level past an @each so an alias is needed
versionSubmitTime: alias('version.submitTime'),
placedCanaries: sumAggregation('taskGroupSummaries', 'placedCanaries'),
desiredCanaries: sumAggregation('taskGroupSummaries', 'desiredCanaries'),
desiredTotal: sumAggregation('taskGroupSummaries', 'desiredTotal'),
placedAllocs: sumAggregation('taskGroupSummaries', 'placedAllocs'),
healthyAllocs: sumAggregation('taskGroupSummaries', 'healthyAllocs'),
unhealthyAllocs: sumAggregation('taskGroupSummaries', 'unhealthyAllocs'),
import { collect, sum } from '@ember/object/computed';
import Model from '@ember-data/model';
import { attr, belongsTo } from '@ember-data/model';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
import sumAggregation from '../utils/properties/sum-aggregation';
import classic from 'ember-classic-decorator';
@classic
export default class JobSummary extends Model {
@belongsTo('job') job;
@fragmentArray('task-group-summary') taskGroupSummaries;
// Aggregate allocation counts across all summaries
@sumAggregation('taskGroupSummaries', 'queuedAllocs') queuedAllocs;
@sumAggregation('taskGroupSummaries', 'startingAllocs') startingAllocs;
@sumAggregation('taskGroupSummaries', 'runningAllocs') runningAllocs;
@sumAggregation('taskGroupSummaries', 'completeAllocs') completeAllocs;
@sumAggregation('taskGroupSummaries', 'failedAllocs') failedAllocs;
@sumAggregation('taskGroupSummaries', 'lostAllocs') lostAllocs;
@collect(
'queuedAllocs',
'startingAllocs',
'runningAllocs',
'completeAllocs',
'failedAllocs',
'lostAllocs'