diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..72fff98 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:3.10.0 + +RUN apk add build-base postgresql-dev python3 python3-dev --no-cache + +COPY . /app +WORKDIR /app +RUN pip3 install -e . + +ENV BULK_SIZE 2000 +ENV MAX_WORKERS 4 + +ENTRYPOINT ["hive2elastic_post"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a51cfe5 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +REPO_SLUG=steemit/hive2elastic #TODO: Make this shell out to git remove -v | grep blah +VERSION=$(shell cat VERSION) + +build: + docker build -t ${REPO_SLUG}:${VERSION} . diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..4e379d2 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.2 diff --git a/prepare_postgres.sql b/prepare_postgres.sql new file mode 100644 index 0000000..774164f --- /dev/null +++ b/prepare_postgres.sql @@ -0,0 +1,21 @@ +CREATE TABLE __h2e_posts +( + post_id INTEGER PRIMARY KEY +); + +INSERT INTO __h2e_posts (post_id) SELECT post_id FROM hive_posts_cache; + +CREATE OR REPLACE FUNCTION __fn_h2e_posts() + RETURNS TRIGGER AS +$func$ +BEGIN + IF NOT EXISTS (SELECT post_id FROM __h2e_posts WHERE post_id = NEW.post_id) THEN + INSERT INTO __h2e_posts (post_id) VALUES (NEW.post_id); + END IF; + RETURN NEW; +END +$func$ LANGUAGE plpgsql; + +CREATE TRIGGER __trg_h2e_posts +AFTER INSERT OR UPDATE ON hive_posts_cache +FOR EACH ROW EXECUTE PROCEDURE __fn_h2e_posts(); diff --git a/setup.py b/setup.py index 63545db..fca0e01 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,19 @@ # coding=utf-8 -import sys +import sys, os from setuptools import find_packages from setuptools import setup assert sys.version_info[0] == 3 and sys.version_info[1] >= 5, "hive2elastic requires Python 3.5 or newer" +# Get version from the VERSION file +here = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(here, 'VERSION'), encoding='utf-8') as f: + version = f.read() + setup( name='hive2elastic', - version='0.0.1', + version=version, description='hive to elastic exporter', long_description=open('README.md').read(), packages=find_packages(),