added 260907 version of worker toolkit

This commit is contained in:
2026-09-08 20:30:51 -04:00
parent cbd3f0f8ca
commit 97aca37663
1283 changed files with 142951 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import DS from 'ember-data';
const {
attr,
Model,
} = DS;
export default Model.extend({
payload: attr(),
});

View File

@@ -0,0 +1,13 @@
import DS from 'ember-data';
export default DS.Model.extend({
startAt: DS.attr(),
endAt: DS.attr(),
//Associations
checkins: DS.hasMany('checkin', { async: false } ),
trackables: DS.hasMany('trackable', { async: false, polymorphic: true, inverse: null } ),
cachedCheckins: DS.hasMany('checkin', { async: false } )
});

View File

@@ -0,0 +1,21 @@
import DS from 'ember-data';
import Ember from 'ember';
import CheckinTrackable from 'flaredown/models/checkin-trackable';
export default CheckinTrackable.extend({
value: DS.attr('number'),
condition: DS.belongsTo('condition'),
setPropsFromCondition: Ember.on('init', Ember.observer('condition', function() {
this.get('condition').then(condition => {
if (Ember.isPresent(condition)) {
this.set('label', condition.get('name'));
if (Ember.isBlank(this.get('colorId'))) {
this.set('colorId', condition.get('colorId'));
}
}
});
}))
});

View File

@@ -0,0 +1,21 @@
import DS from 'ember-data';
import Ember from 'ember';
import CheckinTrackable from 'flaredown/models/checkin-trackable';
export default CheckinTrackable.extend({
value: DS.attr('number'),
symptom: DS.belongsTo('symptom'),
setPropsFromSymptom: Ember.on('init', Ember.observer('symptom', function() {
this.get('symptom').then(symptom => {
if (Ember.isPresent(symptom)) {
this.set('label', symptom.get('name'));
if (Ember.isBlank(this.get('colorId'))) {
this.set('colorId', symptom.get('colorId'));
}
}
});
}))
});

View File

@@ -0,0 +1,10 @@
import DS from 'ember-data';
import Colorable from 'flaredown/mixins/colorable';
import NestedDestroyable from 'flaredown/mixins/nested-destroyable';
export default DS.Model.extend(Colorable, NestedDestroyable, {
position: DS.attr('number'),
checkin: DS.belongsTo('checkin'),
});

View File

@@ -0,0 +1,22 @@
import DS from 'ember-data';
import Ember from 'ember';
import CheckinTrackable from 'flaredown/models/checkin-trackable';
export default CheckinTrackable.extend({
isTaken: DS.attr('boolean'),
treatment: DS.belongsTo('treatment'),
dose: DS.belongsTo('dose', { async: false }),
setPropsFromTreatment: Ember.on('init', Ember.observer('treatment', function() {
this.get('treatment').then(treatment => {
if (Ember.isPresent(treatment)) {
this.set('label', treatment.get('name'));
if (Ember.isBlank(this.get('colorId'))) {
this.set('colorId', treatment.get('colorId'));
}
}
});
}))
});

View File

@@ -0,0 +1,140 @@
import DS from 'ember-data';
import Ember from 'ember';
import moment from 'moment';
const {
attr,
Model,
hasMany,
belongsTo,
} = DS;
const {
A,
get,
set,
RSVP,
isBlank,
computed,
observer,
isPresent,
getProperties,
Logger: { error },
computed: { and, alias },
} = Ember;
export default Model.extend({
date: attr('string'), // please keep this as string as we don't need timezone info
note: attr('string'),
tagIds: attr(),
foodIds: attr(),
postalCode: attr('string'),
availableForPromotion: attr('boolean'),
locationName: attr('string'),
promotionSkippedAt: attr('string'),
tags: hasMany('tag', { async: false }),
foods: hasMany('food', { async: false }),
symptoms: hasMany('checkinSymptom'),
conditions: hasMany('checkinCondition'),
treatments: hasMany('checkinTreatment'),
weather: belongsTo('weather', { async: false }),
harveyBradshawIndex: belongsTo('harveyBradshawIndex', { async: false }),
promotionRate: belongsTo('promotionRate', { async: false }),
tagsChanged: false,
shouldShowPrStep: alias('availableForPromotion'),
addObj: function(obj, idsKey, relationKey) {
const objId = parseInt(get(obj, 'id'));
if (!get(this, idsKey).includes(objId)) {
get(this, relationKey).pushObject(obj);
get(this, idsKey).pushObject(objId);
set(this, 'hasDirtyAttributes', true);
}
},
removeObj: function(obj, idsKey, relationKey) {
get(this, relationKey).removeObject(obj);
get(this, idsKey).removeObject(parseInt(get(obj, 'id')));
set(this, 'hasDirtyAttributes', true);
},
deleteTrackablesPreparedForDestroy() {
const { conditions, symptoms, treatments } = getProperties(this, 'conditions', 'symptoms', 'treatments');
[conditions, symptoms, treatments].forEach(trackables => {
trackables.toArray().forEach(trackable => {
if (get(trackable, 'isPreparedForDestroy')) {
trackables.removeObject(trackable);
trackable.deleteRecord();
}
});
});
},
handleSaveError(obj) {
get(this, 'errors')._add(
'saveFailure',
['Checkin save failed!<br>Please check your connection and then refresh the page.']
);
error(obj);
},
isBlank: and('conditionsBlank', 'symptomsBlank', 'treatmentsBlank', 'tagsBlank', 'noteBlank'),
formattedDate: computed('date', function() {
return moment(get(this, 'date')).format("YYYY-MM-DD");
}),
conditionsBlank: computed('conditions', 'conditions.[]', function() {
return get(this, 'conditions').toArray().filter(function(condition) {
return isPresent(get(condition, 'value'));
}).length === 0;
}),
symptomsBlank: computed('symptoms', 'symptoms.[]', function() {
return get(this, 'symptoms').toArray().filter(function(symptom) {
return isPresent(get(symptom, 'value'));
}).length === 0;
}),
treatmentsBlank: computed('treatments', 'treatments.[]', function() {
return get(this, 'treatments').toArray().filter(function(treatment) {
return get(treatment, 'isTaken');
}).length === 0;
}),
tagsBlank: computed('tags', 'tags.[]', function() {
return get(this, 'tags').toArray().length === 0;
}),
noteBlank: computed('note', function() {
return isBlank(get(this, 'note'));
}),
allColorIds: computed('conditions', 'symptoms', 'treatments', function() {
let result = A();
result.pushObjects(get(this, 'conditions').mapBy('colorId'));
result.pushObjects(get(this, 'symptoms').mapBy('colorId'));
result.pushObjects(get(this, 'treatments').mapBy('colorId'));
return result;
}),
conditionsObserver: observer('conditions', 'conditions.[]', function() {
get(this, 'conditions')
.then(conditions => RSVP.all(conditions.map(c => get(c, 'condition'))))
.then(conditions => set(
this,
'shouldShowHbiStep',
conditions.any(condition => get(condition, 'name') === "Crohn's disease")
));
}).on('init'),
});

View File

@@ -0,0 +1,25 @@
import attr from 'ember-data/attr';
import Ember from 'ember';
import Typeable from 'flaredown/mixins/typeable';
import Reactable from 'flaredown/models/reactable';
import BodyFormatable from 'flaredown/mixins/body-formatable';
import { belongsTo } from 'ember-data/relationships';
const {
computed: {
or,
},
} = Ember;
export default Reactable.extend(Typeable, BodyFormatable, {
body: attr('string'),
userName: attr('string'),
createdAt: attr('date'),
postableId: attr('string'),
notifications: attr(),
post: belongsTo('post'),
hasNotifications: or('notifications.comment', 'notifications.reaction', 'notifications.mention'),
});

View File

@@ -0,0 +1,9 @@
import DS from 'ember-data';
import Trackable from 'flaredown/models/trackable';
export default Trackable.extend({
//Attributes
name: DS.attr('string')
});

View File

@@ -0,0 +1,6 @@
import DS from 'ember-data';
export default DS.Model.extend({
//Attributes
name: DS.attr('string')
});

View File

@@ -0,0 +1,8 @@
import DS from 'ember-data';
import RankedEnum from 'flaredown/models/ranked-enum';
export default RankedEnum.extend({
description: DS.attr('string')
});

View File

@@ -0,0 +1,9 @@
import DS from 'ember-data';
import Searchable from 'flaredown/mixins/searchable';
export default DS.Model.extend(Searchable, {
//Attributes
name: DS.attr('string')
});

View File

@@ -0,0 +1,4 @@
import RankedEnum from 'flaredown/models/ranked-enum';
export default RankedEnum.extend({
});

View File

@@ -0,0 +1,4 @@
import RankedEnum from 'flaredown/models/ranked-enum';
export default RankedEnum.extend({
});

View File

@@ -0,0 +1,8 @@
import DS from 'ember-data';
import Colorable from 'flaredown/mixins/colorable';
export default DS.Model.extend(Colorable, {
name: DS.attr('string'),
colorId: '35',
});

View File

@@ -0,0 +1,98 @@
import DS from 'ember-data';
import Ember from 'ember';
const {
attr,
Model,
belongsTo,
} = DS;
const {
get,
set,
computed,
observer,
getProperties,
} = Ember;
const numericKeys = [
'stools',
'wellBeing',
'abdominalMass',
'abdominalPain',
];
export default Model.extend({
score: attr('number'),
stools: attr('number'),
wellBeing: attr('number'),
abdominalMass: attr('number'),
abdominalPain: attr('number'),
abscess: attr('boolean', { defaultValue: false }),
uveitis: attr('boolean', { defaultValue: false }),
arthralgia: attr('boolean', { defaultValue: false }),
newFistula: attr('boolean', { defaultValue: false }),
analFissure: attr('boolean', { defaultValue: false }),
aphthousUlcers: attr('boolean', { defaultValue: false }),
erythemaNodosum: attr('boolean', { defaultValue: false }),
pyodermaGangrenosum: attr('boolean', { defaultValue: false }),
checkin: belongsTo('checkin'),
wellBeingOptions: [
{ value: 0, label: 'Very well' },
{ value: 1, label: 'Slightly below par' },
{ value: 2, label: 'Poor' },
{ value: 3, label: 'Very poor' },
{ value: 4, label: 'Terrible' },
],
abdominalMassOptions: [
{ value: 0, label: 'None' },
{ value: 1, label: 'Dubious' },
{ value: 2, label: 'Definite' },
{ value: 3, label: 'Definite and tender' },
],
abdominalPainOptions: [
{ value: 0, label: 'None' },
{ value: 1, label: 'Mild' },
{ value: 2, label: 'Moderate' },
{ value: 3, label: 'Severe' },
],
stoolsStringObserver: observer('stoolsString', function() {
const value = get(this, 'stoolsString');
set(this, 'stools', typeof value === 'string' && /\d+/.test(value) ? parseInt(value) : 0);
}),
notReady: computed(...numericKeys, function() {
const numeric = getProperties(this, ...numericKeys);
return numericKeys.any(key => {
let value = numeric[key];
return typeof value !== 'number';
});
}),
selectedWellBeing: computed('wellBeing', function() {
const { wellBeing, wellBeingOptions } = getProperties(this, 'wellBeing', 'wellBeingOptions');
return wellBeingOptions[wellBeing];
}),
selectedAbdominalMass: computed('abdominalMass', function() {
const { abdominalMass, abdominalMassOptions } = getProperties(this, 'abdominalMass', 'abdominalMassOptions');
return abdominalMassOptions[abdominalMass];
}),
selectedAbdominalPain: computed('abdominalPain', function() {
const { abdominalPain, abdominalPainOptions } = getProperties(this, 'abdominalPain', 'abdominalPainOptions');
return abdominalPainOptions[abdominalPain];
}),
});

View File

@@ -0,0 +1,8 @@
import DS from 'ember-data';
export default DS.Model.extend({
user: DS.belongsTo('user', { async: false }),
email: DS.attr('string'),
password: DS.attr('string'),
passwordConfirmation: DS.attr('string')
});

View File

@@ -0,0 +1,13 @@
import attr from 'ember-data/attr';
import Model from 'ember-data/model';
export default Model.extend({
kind: attr('string'),
count: attr('number'),
postId: attr('string'),
postTitle: attr('string'),
unread: attr('boolean'),
notificateableId: attr('string'),
notificateableType: attr('string'),
notifier_username: attr('string'),
});

View File

@@ -0,0 +1,76 @@
import DS from 'ember-data';
import Ember from 'ember';
const {
attr,
Model,
hasMany,
belongsTo,
} = DS;
const {
get,
set,
computed,
getProperties,
$: {
ajax,
},
computed: {
alias,
},
} = Ember;
export default Model.extend({
age: attr('number'),
token: attr('string'),
canEdit: attr('boolean'),
responce: attr(),
symptomIds: attr(),
sex: belongsTo('sex'),
symptoms: hasMany('symptom', { async: false }),
sexId: alias('sex.id'),
apiUrl: '//34.207.197.147:5000/main',
notReady: computed('age', 'sexId', 'symptomIds.[]', function() {
const { age, sexId, symptomIds } = getProperties(this, 'age', 'sexId', 'symptomIds');
return !age || !sexId || !symptomIds.length;
}),
payload: computed('age', 'sexId', 'symptomIds', function() {
const params = getProperties(this, 'age', 'sex.id', 'symptoms');
return {
age: parseInt(params.age),
sex: params['sex.id'],
symptoms: params.symptoms.map(s => getProperties(s, 'name')),
};
}),
addSymptom(symptom) {
get(this, 'symptoms').pushObject(symptom);
get(this, 'symptomIds').pushObject(parseInt(get(symptom, 'id')));
},
removeSymptom(symptom) {
get(this, 'symptoms').removeObject(symptom);
get(this, 'symptomIds').removeObject(parseInt(get(symptom, 'id')));
},
askOracle() {
const data = JSON.stringify(get(this, 'payload'));
return ajax({
data,
url: get(this, 'apiUrl'),
method: 'POST',
dataType: 'json',
contentType: 'application/json; charset=UTF-8',
})
.then(r => set(this, 'responce', r.sortBy('confidence').reverse()));
}
});

View File

@@ -0,0 +1,9 @@
import DS from 'ember-data';
export default DS.Model.extend({
email: DS.attr('string'),
resetPasswordToken: DS.attr('string'),
password: DS.attr('string'),
passwordConfirmation: DS.attr('string'),
currentPassword: DS.attr('string')
});

View File

@@ -0,0 +1,16 @@
import DS from 'ember-data';
import Ember from 'ember';
const {
A,
} = Ember;
export default DS.Model.extend({
name: DS.attr('string'),
startAt: DS.attr('string'),
endAt: DS.attr('string'),
authorName: DS.attr('string'),
includes: DS.attr('raw', {
defaultValue() { return A([]); }
}),
});

View File

@@ -0,0 +1,20 @@
import attr from 'ember-data/attr';
import Typeable from 'flaredown/mixins/typeable';
import Reactable from 'flaredown/models/reactable';
import Topicable from 'flaredown/mixins/topicable';
import BodyFormatable from 'flaredown/mixins/body-formatable';
import { hasMany } from 'ember-data/relationships';
export default Reactable.extend(Typeable, Topicable, BodyFormatable, {
body: attr('string'),
type: attr('string'),
title: attr('string'),
userName: attr('string'),
createdAt: attr('date'),
postableId: attr('string'),
notifications: attr(),
commentsCount: attr('number'),
comments: hasMany('comment', { async: true }),
});

View File

@@ -0,0 +1,11 @@
import DS from 'ember-data';
const {
Model,
hasMany,
} = DS;
export default Model.extend({
posts: hasMany('post', { async: false }),
comments: hasMany('comment', { async: false }),
});

View File

@@ -0,0 +1,58 @@
import Ember from 'ember';
import DS from 'ember-data';
const {
set,
get,
computed,
computed: { not },
} = Ember;
export default DS.Model.extend({
// Attributes
screenName: DS.attr('string'),
birthDate: DS.attr('birthdate'),
dayWalkingHours: DS.attr('number'),
ethnicityIds: DS.attr(),
pressureUnits: DS.attr('string'),
onboardingStepId: DS.attr('string'),
temperatureUnits: DS.attr('string'),
betaTester: DS.attr('boolean'),
notify: DS.attr('boolean'),
checkinReminder: DS.attr('boolean'),
checkinReminderAt: DS.attr('raw'),
timeZoneName: DS.attr('time_zone_name'),
notifyTopPosts: DS.attr('boolean'),
onboardingReminder: DS.attr('boolean', { defaultValue: false }),
// Associations
country: DS.belongsTo('country'),
sex: DS.belongsTo('sex'),
educationLevel: DS.belongsTo('educationLevel'),
dayHabit: DS.belongsTo('dayHabit'),
ethnicities: DS.hasMany('ethnicities'),
onboardingStep: computed('onboardingStepId', {
get() {
let stepId = get(this, 'onboardingStepId') || 'onboarding-personal';
return get(this, `stepsService.steps.${stepId}`);
},
set(_, step) {
set(this, 'onboardingStepId', step.id);
return step.id;
},
}),
// Properties
isOnboarded: not('onboardingStep.nextId'),
// Functions
syncEthnicityIds: Ember.observer('ethnicities', function() {
this.get('ethnicities').then( ethnicities => {
this.set('ethnicityIds', ethnicities.mapBy('id'));
});
})
});

View File

@@ -0,0 +1,13 @@
import DS from 'ember-data';
const {
attr,
Model,
belongsTo,
} = DS;
export default Model.extend({
score: attr('number'),
feedback: attr('string'),
checkin: belongsTo('checkin'),
});

View File

@@ -0,0 +1,8 @@
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
rank: DS.attr('number')
});

View File

@@ -0,0 +1,10 @@
import DS from 'ember-data';
const {
Model,
hasMany,
} = DS;
export default Model.extend({
reactions: hasMany('reaction', { async: false }),
});

View File

@@ -0,0 +1,14 @@
import DS from 'ember-data';
const {
attr,
Model,
} = DS;
export default Model.extend({
count: attr('number'),
value: attr('string'),
participated: attr('boolean'),
reactable_id: attr('string'),
reactable_type: attr('string'),
});

View File

@@ -0,0 +1,19 @@
import DS from 'ember-data';
export default DS.Model.extend({
// Attributes
email: DS.attr('string'),
password: DS.attr('string'),
passwordConfirmation: DS.attr('string'),
screenName: DS.attr('string'),
captchaResponse: DS.attr('string'),
acceptPrivacyTerms: DS.attr('boolean'),
birthDate: DS.attr('birthdate', {
defaultValue() { return new Date(); }
}),
// Associations
user: DS.belongsTo('user', { async: false })
});

View File

@@ -0,0 +1,5 @@
import DS from 'ember-data';
export default DS.Model.extend({
searchables: DS.hasMany('searchable', { async: false, polymorphic: true, inverse: null } ),
});

View File

@@ -0,0 +1,9 @@
import DS from 'ember-data';
export default DS.Model.extend({
baseUrl: DS.attr("string"),
notificationChannel: DS.attr("string"),
facebookAppId: DS.attr("string"),
discourseEnabled: DS.attr("string"),
discourseUrl: DS.attr("string"),
});

View File

@@ -0,0 +1,4 @@
import RankedEnum from 'flaredown/models/ranked-enum';
export default RankedEnum.extend({
});

View File

@@ -0,0 +1,9 @@
import DS from 'ember-data';
import Trackable from 'flaredown/models/trackable';
export default Trackable.extend({
//Attributes
name: DS.attr('string')
});

View File

@@ -0,0 +1,10 @@
import DS from 'ember-data';
import Typeable from 'flaredown/mixins/typeable';
import Colorable from 'flaredown/mixins/colorable';
import Searchable from 'flaredown/mixins/searchable';
export default DS.Model.extend(Typeable, Colorable, Searchable, {
name: DS.attr('string'),
usersCount: DS.attr('number'),
colorId: '35',
});

View File

@@ -0,0 +1,20 @@
import DS from 'ember-data';
import Ember from 'ember';
import Topicable from 'flaredown/mixins/topicable';
const {
attr,
Model,
} = DS;
const {
computed: {
alias,
},
} = Ember;
export default Model.extend(Topicable, {
updatedAt: attr('date'),
topicsCount: alias('topics.length'),
});

View File

@@ -0,0 +1,8 @@
import DS from 'ember-data';
import Typeable from 'flaredown/mixins/typeable';
import Colorable from 'flaredown/mixins/colorable';
import Searchable from 'flaredown/mixins/searchable';
export default DS.Model.extend(Typeable, Colorable, Searchable, {
usersCount: DS.attr('number'),
});

View File

@@ -0,0 +1,15 @@
import DS from 'ember-data';
export default DS.Model.extend({
// Attributes
startAt: DS.attr('date'),
endAt: DS.attr('date'),
trackableType: DS.attr('string'),
colorId: DS.attr('string'),
// Associations
user: DS.belongsTo('user'),
trackable: DS.belongsTo('trackable', { polymorphic: true }),
});

View File

@@ -0,0 +1,9 @@
import DS from 'ember-data';
import Trackable from 'flaredown/models/trackable';
export default Trackable.extend({
//Attributes
name: DS.attr('string')
});

View File

@@ -0,0 +1,11 @@
import DS from 'ember-data';
export default DS.Model.extend({
//Attributes
email: DS.attr('string'),
createdAt: DS.attr('date'),
//Associations
profile: DS.belongsTo('profile'),
topicFollowing: DS.belongsTo('topic-following'),
});

View File

@@ -0,0 +1,44 @@
import DS from 'ember-data';
import Ember from 'ember';
import FieldsByUnits from 'flaredown/mixins/fields-by-units';
let { Model, attr } = DS;
let { get, computed } = Ember;
export default Model.extend(FieldsByUnits, {
humidity: attr('number'),
icon: attr('string'),
precipIntensity: attr('number'),
pressure: attr('number'),
summary: attr('string'),
temperatureMax: attr('number'),
temperatureMin: attr('number'),
pressureInches: computed('pressure', function() {
return Math.round((29.92 * get(this, 'pressure')) / 10.1325) / 100;
}),
temperatureMaxCelsius: computed('temperatureMax', function() {
return this.fahrenheitToCelsius(get(this, 'temperatureMax'));
}),
temperatureMinCelsius: computed('temperatureMin', function() {
return this.fahrenheitToCelsius(get(this, 'temperatureMin'));
}),
fahrenheitToCelsius(temp) {
return Math.round((temp - 32) * 100 / 180);
},
pressureByUnits(unit) {
return get(this, this.pressureFieldByUnits(unit));
},
temperatureMinByUnits(unit) {
return get(this, unit === 'c' ? 'temperatureMinCelsius' : 'temperatureMin');
},
temperatureMaxByUnits(unit) {
return get(this, unit === 'c' ? 'temperatureMaxCelsius' : 'temperatureMax');
},
});