Exemplo n.º 1
0
class Game(AioModel):
    __table_name__ = "game"
    __keyspace__ = "presidents"
    game_id = UUID(primary_key=True, partition_key=True, required=True)
    user_ids = List(value_type=UUID, required=False)
    creation_timestamp = DateTime(required=True)
    destruction_timestamp = DateTime(required=False)
    round_ids = List(value_type=UUID, required=False)
    pause_start_timestamps = List(value_type=DateTime, required=False)
    pause_end_timestamps = List(value_type=DateTime, required=False)
Exemplo n.º 2
0
class Recommendation(Model):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    user_gid = Integer(required=True, index=True)
    username = Text()
    user_image = Text()
    item_recommended = List(Integer)
    books_details_recommended = List(UserDefinedType(book))
    precision = Double(default=0.0, index=True)
    recall = Double(default=0.0, index=True)
    book_details_retrieved = Boolean(default=False, index=True)
    most_common_shelves = List(UserDefinedType(shelve), required=False)
    common_shelves_retrieved = Boolean(default=False, index=True)
Exemplo n.º 3
0
class GameClicks(AioModel):
    __table_name__ = "game_user_clicks"
    __keyspace__ = "presidents"
    game_id = UUID(primary_key=True, partition_key=True, required=True)
    user_id = UUID(primary_key=True, partition_key=True, required=True)
    action = Text(primary_key=True, required=True, clustering_order="ASC")
    timestamps = List(value_type=DateTime, required=True)
Exemplo n.º 4
0
def _str_to_column(type_str, key_type=None, value_type=None, column_def={}):
    '''
    Converts name of Cassandra types to driver class wrapper for
    that type.
    '''
    type_str = type_str.lower()

    if type_str == 'integer':
        return Integer(**column_def)
    elif type_str == 'text':
        return Text(**column_def)
    elif type_str == 'ascii':
        return Ascii(**column_def)
    elif type_str == 'bigint':
        return BigInt(**column_def)
    elif type_str == 'blob':
        return Blob(**column_def)
    elif type_str == 'bytes':
        return Bytes(**column_def)
    elif type_str == 'boolean':
        return Boolean(**column_def)
    elif type_str == 'counter':
        return Counter(**column_def)
    elif type_str == 'date':
        return Date(**column_def)
    elif type_str == 'datetime':
        return DateTime(**column_def)
    elif type_str == 'decimal':
        return Decimal(**column_def)
    elif type_str == 'double':
        return Double(**column_def)
    elif type_str == 'float':
        return Float(**column_def)
    elif type_str == 'list':
        _assert_type_exception(value_type, "list type requires value_type")
        return List(value_type=value_type, **column_def)
    elif type_str == 'map':
        _assert_type_exception(key_type, "list type requires key_type")
        _assert_type_exception(value_type, "list type requires value_type")
        return Map(key_type=key_type, value_type=value_type, **column_def)
    elif type_str == 'set':
        _assert_type_exception(value_type, "set type requires value_type")
        return Set(value_type=value_type, **column_def)
    elif type_str == 'smallint':
        return SmallInt(**column_def)
    elif type_str == 'time':
        return Time(**column_def)
    elif type_str == 'timeuuid':
        return TimeUUID(**column_def)
    elif type_str == 'timestamp':
        return TimeUUID(**column_def)
    elif type_str == 'tinyint':
        return TinyInt(**column_def)
    elif type_str == 'uuid':
        return UUID(**column_def)
    elif type_str == 'varint':
        return VarInt(**column_def)
    else:
        raise Exception('Type {} is not defined.'.format(type_str))
Exemplo n.º 5
0
class User(UserType):
    # We use Date and Time to ensure to_python
    # is called for these columns
    age = Integer()
    date_param = Date()
    map_param = Map(Integer, Time)
    list_param = List(Date)
    set_param = Set(Date)
    tuple_param = Tuple(Date, Decimal, Boolean, VarInt, Double, UUID)
Exemplo n.º 6
0
class Books(Model):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(primary_key=True, required=True, index=True)
    title = Text(required=True, index=True)
    isbn = Text()
    isbn13 = Text()
    publication_date = DateTime(index=True)
    description = Text()
    average_rating = Double(required=True, index=True)
    ratings_count = Integer(required=True)
    reviews_count = Integer()
    small_book = Boolean(
        default=True,
        index=True)  # no shelves, review_count, description, smilar_book
    author = UserDefinedType(author, default=author())
    #Specific to model
    reviews_retrieved = Boolean(default=False, required=False, index=True)
    shelves_retrieved = Boolean(default=False, required=False, index=True)
    #Lists
    list_shelves = List(UserDefinedType(shelve), required=False)
    list_reviews = List(UserDefinedType(review), required=False)
Exemplo n.º 7
0
class User(AioModel):
    __table_name__ = "user"
    __keyspace__ = "presidents"
    user_id = UUID(primary_key=True, partition_key=True, required=True)
    username = Text(
        required=True, index=True
    )  # TODO: maintain separate Username table for this when affordable
    previous_usernames = List(value_type=Text)
    password = Text(required=True)  # hashed
    created = DateTime(required=True)
    # stores all user preferences like unselecting cards on store hand,
    # etc.
    settings = Map(key_type=Text, value_type=Text)
Exemplo n.º 8
0
class Users(Model):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(required=True, index=True)
    name = Text(required=True, index=True)
    friends_count = Integer()
    reviews_count = Integer(index=True)
    age = Integer(index=True)
    gender = Text(index=True)
    location = Text(index=True)
    small_user = Boolean(default=False, index=True)
    private = Boolean(default=False, index=True)
    #specific to model
    friends_retrieved = Boolean(default=False, index=True)
    reviews_retrieved = Boolean(default=False, index=True)
    shelves_reviews_retrieved = Boolean(default=False, index=True)
    reviews_filtered = Boolean(default=False, index=True)
    test_set = Boolean(default=False, index=True)

    #Lists
    list_reviews = List(UserDefinedType(review))
    list_friends = List(UserDefinedType(user))
    short_list_reviews = List(UserDefinedType(review))
    most_common_shelves = List(UserDefinedType(shelve), required=False)
Exemplo n.º 9
0
class book(UserType):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(required=True, index=True)
    title = Text(required=True, index=True)
    isbn = Text(index=True)
    isbn13 = Text()
    publication_date = DateTime(index=True)
    description = Text()
    average_rating = Double(required=True, index=True)
    ratings_count = Integer(required=True)
    reviews_count = Integer()
    small_book = Boolean(
    )  # no shelves, review_count, description, smilar_book
    author = UserDefinedType(author, default=author())
    list_shelves = List(UserDefinedType(shelve))
    error_retrieving_shelves = Boolean(default=False)
Exemplo n.º 10
0
class Authors(Model):
    id = UUID(primary_key=True, default=uuid.uuid4(), partition_key=True)
    name = Text(required=True, index=True)
    gid = Integer(required=True, index=True)
    age = Integer(index=True)
    gender = Text(index=True)
    location = Text(index=True)
    interests = Text()
    born_at = DateTime(index=True)
    diet_at = DateTime(index=True)
    friends_count = Integer()
    reviews_count = Integer()
    fans_count = Integer()
    author_followers_count = Integer()
    works_count = Integer()
    average_rating = Double()
    ratings_count = Integer()
    text_reviews_count = Integer()
    #Lists
    list_books = List(UserDefinedType(book))
Exemplo n.º 11
0
class Product(Model):
    # Elassandra internal
    es_query = EsQuery()

    # Identification
    code = Text(primary_key=True)
    url = Text()
    creator = Text()
    created_t = DateTime()
    last_modified_t = DateTime()
    product_name = Text()
    generic_name = Text()

    # Base information
    quantity = Text()
    packaging = List(Text)
    packaging_tags = List(Text)
    brands = List(Text)
    brands_tags = List(Text)
    categories = List(Text)
    categories_tags = List(Text)
    categories_fr = List(Text)
    origins = List(Text)
    origins_tags = List(Text)
    manufacturing_places = List(Text)
    manufacturing_places_tags = List(Text)
    labels = List(Text)
    labels_tags = List(Text)
    labels_fr = List(Text)
    emb_codes = List(Text)
    emb_codes_tags = List(Text)
    first_packaging_code_geo = Text()  # mapped to geopoint by elasticsearch
    cities = List(Text)
    cities_tags = List(Text)
    purchase_places = Text()
    stores = List(Text)
    countries = Text()
    countries_tags = List(Text)
    countries_fr = List(Text)
    ingredients_text = Text()  # mapped to text by elasticsearch
    allergens = List(Text)
    allergens_fr = List(Text)
    traces = List(Text)
    traces_tags = List(Text)
    traces_fr = List(Text)
    serving_size = Text()
    serving_quantity = Double()
    no_nutriments = Text()
    additives_n = Integer()
    additives = Text()  # Not indexed, could be analyzed as text
    additives_tags = List(Text)
    additives_fr = List(Text)
    ingredients_from_palm_oil_n = Integer()
    ingredients_from_palm_oil = Text()
    ingredients_from_palm_oil_tags = List(Text)
    ingredients_that_may_be_from_palm_oil_n = Integer()
    ingredients_that_may_be_from_palm_oil = Text()
    ingredients_that_may_be_from_palm_oil_tags = List(Text)
    nutrition_grade_uk = Text()
    nutrition_grade_fr = Text()
    pnns_groups_1 = Text()
    pnns_groups_2 = Text()
    states = List(Text)
    states_tags = List(Text)
    states_fr = List(Text)
    main_category = List(Text)
    main_category_fr = List(Text)

    # URLs
    image_url = Text()
    image_small_url = Text()
    image_ingredients_url = Text()
    image_ingredients_small_url = Text()
    image_nutrition_url = Text()
    image_nutrition_small_url = Text()

    # Composition
    energy_100g = Double()
    energy_from_fat_100g = Double(db_field="energy-from-fat_100g")
    fat_100g = Double()
    saturated_fat_100g = Double(db_field="saturated-fat_100g")
    butyric_acid_100g = Double(db_field="butyric-acid_100g")
    caproic_acid_100g = Double(db_field="caproic-acid_100g")
    caprylic_acid_100g = Double(db_field="caprylic-acid_100g")
    capric_acid_100g = Double(db_field="capric-acid_100g")
    lauric_acid_100g = Double(db_field="lauric-acid_100g")
    myristic_acid_100g = Double(db_field="myristic-acid_100g")
    palmitic_acid_100g = Double(db_field="palmitic-acid_100g")
    stearic_acid_100g = Double(db_field="stearic-acid_100g")
    arachidic_acid_100g = Double(db_field="arachidic-acid_100g")
    behenic_acid_100g = Double(db_field="behenic-acid_100g")
    lignoceric_acid_100g = Double(db_field="lignoceric-acid_100g")
    cerotic_acid_100g = Double(db_field="cerotic-acid_100g")
    montanic_acid_100g = Double(db_field="montanic-acid_100g")
    melissic_acid_100g = Double(db_field="melissic-acid_100g")
    monounsaturated_fat_100g = Double(db_field="monounsaturated-fat_100g")
    polyunsaturated_fat_100g = Double(db_field="polyunsaturated-fat_100g")
    omega_3_fat_100g = Double(db_field="omega-3-fat_100g")
    alpha_linolenic_acid_100g = Double(db_field="alpha-linolenic-acid_100g")
    eicosapentaenoic_acid_100g = Double(db_field="eicosapentaenoic-acid_100g")
    docosahexaenoic_acid_100g = Double(db_field="docosahexaenoic-acid_100g")
    omega_6_fat_100g = Double(db_field="omega-6-fat_100g")
    linoleic_acid_100g = Double(db_field="linoleic-acid_100g")
    arachidonic_acid_100g = Double(db_field="arachidonic-acid_100g")
    gamma_linolenic_acid_100g = Double(db_field="gamma-linolenic-acid_100g")
    dihomo_gamma_linolenic_acid_100g = Double(db_field="dihomo-gamma-linolenic-acid_100g")
    omega_9_fat_100g = Double(db_field="omega-9-fat_100g")
    oleic_acid_100g = Double(db_field="oleic-acid_100g")
    elaidic_acid_100g = Double(db_field="elaidic-acid_100g")
    gondoic_acid_100g = Double(db_field="gondoic-acid_100g")
    mead_acid_100g = Double(db_field="mead-acid_100g")
    erucic_acid_100g = Double(db_field="erucic-acid_100g")
    nervonic_acid_100g = Double(db_field="nervonic-acid_100g")
    trans_fat_100g = Double(db_field="trans-fat_100g")
    cholesterol_100g = Double()
    carbohydrates_100g = Double()
    sugars_100g = Double()
    sucrose_100g = Double()
    glucose_100g = Double()
    fructose_100g = Double()
    lactose_100g = Double()
    maltose_100g = Double()
    maltodextrins_100g = Double()
    starch_100g = Double()
    polyols_100g = Double()
    fiber_100g = Double()
    proteins_100g = Double()
    casein_100g = Double()
    serum_proteins_100g = Double(db_field="serum-proteins_100g")
    nucleotides_100g = Double()
    salt_100g = Double()
    sodium_100g = Double()
    alcohol_100g = Double()
    vitamin_a_100g = Double(db_field="vitamin-a_100g")
    beta_carotene_100g = Double(db_field="beta-carotene_100g")
    vitamin_d_100g = Double(db_field="vitamin-d_100g")
    vitamin_e_100g = Double(db_field="vitamin-e_100g")
    vitamin_k_100g = Double(db_field="vitamin-k_100g")
    vitamin_c_100g = Double(db_field="vitamin-c_100g")
    vitamin_b1_100g = Double(db_field="vitamin-b1_100g")
    vitamin_b2_100g = Double(db_field="vitamin-b2_100g")
    vitamin_pp_100g = Double(db_field="vitamin-pp_100g")
    vitamin_b6_100g = Double(db_field="vitamin-b6_100g")
    vitamin_b9_100g = Double(db_field="vitamin-b9_100g")
    folates_100g = Double()
    vitamin_b12_100g = Double(db_field="vitamin-b12_100g")
    biotin_100g = Double()
    pantothenic_acid_100g = Double(db_field="pantothenic-acid_100g")
    silica_100g = Double()
    bicarbonate_100g = Double()
    potassium_100g = Double()
    chloride_100g = Double()
    calcium_100g = Double()
    phosphorus_100g = Double()
    iron_100g = Double()
    magnesium_100g = Double()
    zinc_100g = Double()
    copper_100g = Double()
    manganese_100g = Double()
    fluoride_100g = Double()
    selenium_100g = Double()
    chromium_100g = Double()
    molybdenum_100g = Double()
    iodine_100g = Double()
    caffeine_100g = Double()
    taurine_100g = Double()
    ph_100g = Double()
    fruits_vegetables_nuts_100g = Double(db_field="fruits-vegetables-nuts_100g")
    fruits_vegetables_nuts_estimate_100g = Double(db_field="fruits-vegetables-nuts-estimate_100g")
    collagen_meat_protein_ratio_100g = Double(db_field="collagen-meat-protein-ratio_100g")
    cocoa_100g = Double()
    chlorophyl_100g = Double()
    carbon_footprint_100g = Double(db_field="carbon-footprint_100g")
    nutrition_score_fr_100g = Double(db_field="nutrition-score-fr_100g")
    nutrition_score_uk_100g = Double(db_field="nutrition-score-uk_100g")
    glycemic_index_100g = Double(db_field="glycemic-index_100g")
    water_hardness_100g = Double(db_field="water-hardness_100g")
    choline_100g = Double()
    phylloquinone_100g = Double()
    beta_glucan_100g = Double(db_field="beta-glucan_100g")
    inositol_100g = Double()
    carnitine_100g = Double()

    def to_dict(self):
        json_dict = dict(self)
        del json_dict['es_query']
        return json_dict
Exemplo n.º 12
0
 def test_update_list_append_with_empty_list(self):
     us = UpdateStatement('table')
     us.add_update(List(Text, db_field='a'), [], 'append')
     self.assertFalse(us.assignments)
Exemplo n.º 13
0
 def test_update_list_append_with_empty_list(self):
     us = UpdateStatement('table')
     us.add_assignment_clause(
         ListUpdateClause('a', List.Quoter([]), operation='append'))
     self.assertEqual(six.text_type(us),
                      'UPDATE table SET "a" = "a" + %(0)s')
Exemplo n.º 14
0
class UserLeavetimes(AioModel):
    __table_name__ = "user_leave_timestamps"
    __keyspace__ = "presidents"
    user_id = UUID(primary_key=True, partition_key=True, required=True)
    game_id = UUID(primary_key=True, partition_key=True, required=True)
    leave_timestamps = List(value_type=DateTime, required=False)
Exemplo n.º 15
0
class UserGames(AioModel):
    __table_name__ = "user_games"
    __keyspace__ = "presidents"
    user_id = UUID(primary_key=True, partition_key=True, required=True)
    game_ids = List(value_type=UUID, required=False)
Exemplo n.º 16
0
class Shelves(Model):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer()
    shelve = Text(required=True, index=True)
    count = Integer()
    list_book = List(UserDefinedType(book))
Exemplo n.º 17
0
class RoundCards(AioModel):
    __table_name__ = "round_cards"
    __keyspace__ = "presidents"
    round_id = UUID(primary_key=True, partition_key=True, required=True)
    spot = TinyInt(primary_key=True, required=True, clustering_order="ASC")
    cards = List(value_type=TinyInt, required=True)
Exemplo n.º 18
0
class textblob(UserType):
    instantiated = Boolean()
    tags = List(UserDefinedType(tb_tag))
    noun_phrases = List(Text)
    sentences = List(UserDefinedType(tb_sentence))