-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77b4c07
commit 84e0fa0
Showing
30 changed files
with
2,857 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
# Keep environment variables out of version control | ||
.env | ||
logs | ||
dist |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM node:20-alpine3.19 | ||
|
||
WORKDIR /var/kafka | ||
|
||
COPY package.json ./ | ||
COPY package-lock.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
RUN npm run build | ||
|
||
# Add a health check to verify the application is running | ||
# HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ | ||
# CMD curl --fail http://localhost:8080/health || exit 1 | ||
|
||
CMD [ "npm", "run", "start" ] |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- Create a materialized view for total visits per code | ||
CREATE MATERIALIZED VIEW public.total_visits_per_code AS | ||
SELECT | ||
code, | ||
COUNT(*) AS total_visits | ||
FROM | ||
public."ClickAnalytics" | ||
GROUP BY | ||
code; | ||
|
||
-- Optional: Create an index on the materialized view for faster lookups | ||
CREATE INDEX idx_total_visits_per_code ON public.total_visits_per_code (code); | ||
|
||
|
||
CREATE OR REPLACE FUNCTION refresh_total_visits_per_code() | ||
RETURNS TRIGGER AS $$ | ||
BEGIN | ||
-- Refresh the materialized view | ||
PERFORM pg_notify('refresh_total_visits', 'Refreshing total visits view'); | ||
REFRESH MATERIALIZED VIEW public.total_visits_per_code; | ||
RETURN NULL; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
|
||
CREATE TRIGGER refresh_view_on_clickanalytics_update | ||
AFTER INSERT OR UPDATE OR DELETE ON public."ClickAnalytics" | ||
FOR EACH STATEMENT | ||
EXECUTE FUNCTION refresh_total_visits_per_code(); |
Oops, something went wrong.