Skip to content

Commit

Permalink
Merge pull request #43 from cu-devclub/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spyspoisspuis authored Mar 30, 2024
2 parents 7de4f0b + 664a703 commit dbb6e09
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/datasource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
- name: Copy Data source directory to Server
run: |
scp -i ~/.ssh/id_rsa data ${{ secrets.LINUX_USERNAME }}@${{ secrets.LINUX_HOST }}:~/dhammanava-search
scp -r -i ~/.ssh/id_rsa data ${{ secrets.LINUX_USERNAME }}@${{ secrets.LINUX_HOST }}:~/dhammanava-search
2 changes: 1 addition & 1 deletion .github/workflows/monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
key: ${{ secrets.LINUX_PRIVATE_KEY }}
script: |
cd dhammanava-search
docker compose -f docker-compose.prod.yml up -d loki promtail grafana
docker compose -f docker-compose.prod.yml up -d loki promtail grafana prometheus
7 changes: 6 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
- 8081:8081
depends_on:
- elastic-db
- rabbitmq
labels:
logging: "promtail"
loggin_jobname: "containerlogs"
Expand Down Expand Up @@ -153,6 +154,9 @@ services:
loggin_jobname: "containerlogs"
depends_on:
- data-db
- rabbitmq
- auth-service
- search-service
networks:
- dhammanava_network

Expand All @@ -173,6 +177,7 @@ services:

rabbitmq:
image: "rabbitmq:3.12-management"
container_name: rabbitmq
ports:
- "5672:5672"
- "15672:15672"
Expand Down Expand Up @@ -223,13 +228,13 @@ services:

grafana:
image: grafana/grafana:10.3.5
container_name: grafana
ports:
- 3000:3000
volumes:
- ./monitoring/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
- ./monitoring/grafana/main-dashboard.json:/var/lib/grafana/dashboards/dashboard.json
- ./monitoring/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/main.yml
- ./monitoring/grafana/grafana.ini:/etc/grafana/grafana.ini
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
Expand Down
16 changes: 13 additions & 3 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
restart: always
depends_on:
- elastic-db
- rabbitmq
networks:
- dhammanava_network

Expand Down Expand Up @@ -57,6 +58,9 @@ services:
ports:
- 9200:9200
restart: always
labels:
logging: "promtail"
loggin_jobname: "containerlogs"
mem_limit: 1g
networks:
- dhammanava_network
Expand Down Expand Up @@ -141,6 +145,9 @@ services:
restart: always
depends_on:
- data-db
- rabbitmq
- auth-service
- search-service
labels:
logging: "promtail"
loggin_jobname: "containerlogs"
Expand All @@ -164,6 +171,7 @@ services:

rabbitmq:
image: "rabbitmq:3-alpine"
container_name: rabbitmq-container
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USERNAME}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
Expand Down Expand Up @@ -208,6 +216,8 @@ services:
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml
volumes:
- ./volumes/monitoring/loki:/loki
networks:
- dhammanava_network

Expand All @@ -226,6 +236,7 @@ services:

grafana:
image: grafana/grafana:10.3.5
container_name: grafana
ports:
- 3000:3000
volumes:
Expand All @@ -234,9 +245,7 @@ services:
- ./monitoring/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/main.yml
- ./monitoring/grafana/grafana.ini.prod:/etc/grafana/grafana.ini
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_AUTH_DISABLE_LOGIN_FORM=false
- GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
networks:
Expand All @@ -247,6 +256,7 @@ services:
container_name: prometheus
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
- ./volumes/monitoring/prometheus:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
networks:
Expand Down
1 change: 1 addition & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_EVALUATION_FORM_URL=DHAMMANAVA_EVALUATION_FORM_URL
2 changes: 1 addition & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.env.production
!.env
9 changes: 8 additions & 1 deletion frontend/src/components/search/SearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SearchIcon } from "@chakra-ui/icons";
import { useState } from "react";
import { searchService } from "../../service/search";
import { SearchResultInterface } from "../../models/qa";
import { SEARCH_STATUS, SEARCH_TYPE } from "../../constant";

interface SearchOptions {
key: string;
Expand Down Expand Up @@ -121,7 +122,7 @@ function SearchField({
if (q) {
query = q.question;
}
const response = await searchService(query);
const response = await searchService(query,SEARCH_TYPE.DEFAULT,SEARCH_STATUS.CONFIRM);

const tokens = [query, ...response.tokens];

Expand Down Expand Up @@ -151,6 +152,12 @@ function SearchField({
</InputLeftElement>
<AutoCompleteInput
onChange={onChangeInputHandler}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onKeyDown={(e: any) => {
if (e.key === "Enter") {
onSelectInputHandle(e);
}
}}
variant="search_bar"
value={searchParam || ""}
placeholder="ค้นหาเลย"
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,14 @@ export const REQUEST_STATUS = {
PENDING: "pending",
REVIEWED: "reviewed",
};

export const SEARCH_STATUS = {
DRAFT : "draft",
CONFIRM : "confirm",
DEFAULT : "draft"
}

export const SEARCH_TYPE = {
TF_IDF: "tf_idf",
DEFAULT: "tf_idf"
}
7 changes: 5 additions & 2 deletions frontend/src/service/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ import axios from "../axiosInstance";
import { CreateCustomError } from "../error";
import { DataItem, SearchResultInterface } from "../../models/qa";
import { searchURL } from "../../constant/serviceURL";
import { SEARCH_STATUS, SEARCH_TYPE } from "../../constant";
/**
* Performs a search query using the specified query string.
*
* @param {string} query - The search query string.
* @param {string} searchType - Optional. The search type to use. Defaults to "tf_idf".
* @param {string} searchStatus - Optional. The search status to use. Defaults to "draft".
* @return {Promise<SearchResultInterface>} - A promise that resolves with the search results.
*/
export const searchService = async (
query: string,
searchType: string = "tf_idf"
searchType: string = SEARCH_TYPE.DEFAULT,
searchStatus: string = SEARCH_STATUS.DEFAULT
): Promise<SearchResultInterface> => {
try {
const response = await axios.get(
`${searchURL}/search?query=${query}&searchType=${searchType}`
`${searchURL}/search?query=${query}&searchType=${searchType}&searchStatus=${searchStatus}`
);

const records: DataItem[] = response.data.results.map((item: DataItem) => {
Expand Down
Loading

0 comments on commit dbb6e09

Please sign in to comment.