# Path: gogdb/core/normalization.py
# def normalize_search(search_str):
#     if search_str is None:
#         return ""
#     return "".join(c for c in search_str.lower() if c in NORMALIZED_CHARS)
# 
# def compress_systems(systems):
#     """Compressed systems is just a string of the first letters"""
#     compressed = ""
#     for system in systems:
#         compressed += system[0]
#     return compressed


import json
import sqlite3
import dataclasses
import os
import collections
import logging
import flask
import gogdb.core.storage as storage
import gogdb.core.model as model
from gogdb.core.normalization import normalize_search, compress_systems
        timestamp REAL,
        action TEXT,
        category TEXT,
        dl_type TEXT,
        bonus_type TEXT,
        property_name TEXT,
        serialized_record TEXT
    );""")
    cur.execute("""CREATE TABLE changelog_summary (
        product_id INTEGER,
        product_title TEXT,
        timestamp REAL,
        categories TEXT
    );""")
    cur.execute("CREATE INDEX idx_products_sale_rank ON products (sale_rank)")
    cur.execute("CREATE INDEX idx_changelog_timestamp ON changelog (timestamp)")
    cur.execute("CREATE INDEX idx_summary_timestamp ON changelog_summary (timestamp)")

def count_rows(cur, table_name):
    cur.execute(f"SELECT COUNT(*) FROM {table_name};")
    return cur.fetchone()[0]

def index_product(prod, cur):
    cur.execute(
        "INSERT INTO products VALUES (?, ?, ?, ?, ?, ?, ?)",
        (
            prod.id,
            prod.title,
            prod.image_logo,
            prod.type,

# Path: gogdb/core/normalization.py
# def normalize_search(search_str):
#     if search_str is None:
#         return ""
#     return "".join(c for c in search_str.lower() if c in NORMALIZED_CHARS)
# 
# def compress_systems(systems):
#     """Compressed systems is just a string of the first letters"""
#     compressed = ""
#     for system in systems:
#         compressed += system[0]
#     return compressed


# Path: gogdb/updater/gen_index.py
import json
import sqlite3
import dataclasses
import os
import collections
import logging
import flask
import gogdb.core.storage as storage
import gogdb.core.model as model
from gogdb.core.normalization import normalize_search, compress_systems

        timestamp REAL,
        action TEXT,
        category TEXT,
        dl_type TEXT,
        bonus_type TEXT,
        property_name TEXT,
        serialized_record TEXT
    );""")
    cur.execute("""CREATE TABLE changelog_summary (
        product_id INTEGER,
        product_title TEXT,
        timestamp REAL,
        categories TEXT
    );""")
    cur.execute("CREATE INDEX idx_products_sale_rank ON products (sale_rank)")
    cur.execute("CREATE INDEX idx_changelog_timestamp ON changelog (timestamp)")
    cur.execute("CREATE INDEX idx_summary_timestamp ON changelog_summary (timestamp)")

def count_rows(cur, table_name):
    cur.execute(f"SELECT COUNT(*) FROM {table_name};")
    return cur.fetchone()[0]

def index_product(prod, cur):
    cur.execute(
        "INSERT INTO products VALUES (?, ?, ?, ?, ?, ?, ?)",
        (
            prod.id,
            prod.title,
            prod.image_logo,
            prod.type,

            compress_systems(prod.comp_systems),