This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -x | |
set -e | |
PREVIOUS_CONTAINER=$(docker ps --format "table {{.ID}} {{.Names}} {{.CreatedAt}}" | grep web | awk -F " " '{print $1}') | |
docker-compose up -d --no-deps --scale web=2 --no-recreate web | |
sleep 30 | |
docker kill -s SIGTERM $PREVIOUS_CONTAINER | |
sleep 1 | |
docker rm -f $PREVIOUS_CONTAINER | |
docker-compose up -d --no-deps --scale web=1 --no-recreate web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"os" | |
"os/signal" | |
"sync" | |
"syscall" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select to_json(a) | |
from ( | |
select d1.*, | |
( | |
select to_json(t) from | |
(select * from document d2 | |
where type = 'author' | |
and d2.id = (d1.body->>'author_id')::int | |
) t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- my table is called 'document', is has a type (text) and a document (jsonb) colum | |
select d1.*, | |
( | |
select to_json(t) from | |
(select * from document d2 | |
where type = 'author' | |
and d2.id = (d1.body->>'author_id')::int | |
) t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
answer_options_table = Q()\ | |
.tables(ModuleAnswerOption.s)\ | |
.fields(ModuleAnswerOption.s.pk, ModuleAnswerOption.s.answer, ModuleAnswerOption.s.is_correct) \ | |
.where(ModuleAnswerOption.s.question == ModuleQuestion.s.pk)\ | |
.as_table('g') | |
answer_options_json_q = Q() \ | |
.tables(answer_options_table) \ | |
.fields(func.json_agg(answer_options_table).as_('options')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlbuilder.smartsql.expressions import func | |
from sqlbuilder.smartsql import Q | |
from core.models import AppLicenseGroup, AppLicenseGroupUser | |
from core.utils.db import fetch_many, fetch_one, norm_sum | |
from itrain.models import ModuleResponse, Module, ModuleAssignee | |
def fetch_average_to_complete(company_id, start_date, end_date): | |
company_filter = Module.s.company_id == company_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlbuilder.smartsql.expressions import func | |
from sqlbuilder.smartsql import Q | |
from core.models import AppLicenseGroup, AppLicenseGroupUser | |
from core.utils.db import fetch_many, fetch_one, norm_sum | |
from itrain.models import ModuleResponse, Module, ModuleAssignee | |
def fetch_average_to_complete(company_id, start_date, end_date): | |
company_filter = Module.s.company_id == company_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joins = (Sale.s & Product.s).on(Sale.s.product == Product.s.pk) | |
where = (Product.s.company_id == company_id) & \ | |
(Sale.s.created_at.between(func.date(start_date), func.date(end_date))) | |
inner_table = Q()\ | |
.tables( | |
(joins + CategoryAssignment.s).on(CategoryAssignment.s.product == Product.s.pk) | |
)\ | |
.fields( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"tot": 1, | |
"date": "2017-09-08", | |
"category_id": 3, | |
"name": "Uniform Issues" | |
}, | |
{ | |
"tot": 1, | |
"date": "2017-09-06", | |
"category_id": 3, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { when, reaction } from "mobx"; | |
import { types, getParent, getRoot, getSnapshot, applySnapshot } from "mobx-state-tree"; | |
import uuid from 'uuid/v4' | |
import request from '../api' | |
const AuthStore = types.model( | |
'AuthStore', | |
{ | |
token: '', | |
isLoading: false |
NewerOlder