Skip to content

Commit 74cc49a

Browse files
committed
fix cr
2 parents 31ec762 + a2073fd commit 74cc49a

36 files changed

+620
-301
lines changed

.github/workflows/deploy.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and Push Docker image
2+
3+
on:
4+
# Build from input box
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Version'
9+
required: true
10+
11+
env:
12+
VERSION: ${{ github.event.inputs.version }}
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
21+
# Use Caching for npm
22+
- name: Cache node modules
23+
uses: actions/cache@v2
24+
with:
25+
working-directory: ./ui
26+
path: |
27+
node_modules
28+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
29+
restore-keys: |
30+
${{ runner.os }}-npm-
31+
32+
- name: Install npm dependencies and build UI
33+
run: |
34+
cd ui
35+
npm install
36+
npm run build
37+
38+
- name: Create and use Docker buildx builder
39+
run: |
40+
sudo docker buildx create --use
41+
- name: Build and push Docker image
42+
run: |
43+
sudo docker buildx build \
44+
--platform linux/amd64,linux/arm64 \
45+
-t gerev/gerev:$VERSION \
46+
-t gerev/gerev:latest \
47+
--push .

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ COPY ./app/requirements.txt /tmp/requirements.txt
66

77
RUN pip install -r /tmp/requirements.txt
88

9+
ENV CAPTURE_TELEMETRY=1
10+
911
COPY ./app/models.py /tmp/models.py
1012

1113
# cache the models

README.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
1-
# Workplace search reimagined
2-
self hosted workplace search engine, search your entire company from a single place.
1+
## Join Discord for early access code!
32

4-
![gerev](./images/product-example.png)
3+
![Discord Shield](https://discordapp.com/api/guilds/1060085859497549844/widget.png?style=shield)
54

5+
[Join here!](https://discord.gg/zZZrUBZd)
6+
# Gerev - Workplace search for Devs
7+
8+
9+
Tired of searching for that one document you know exists somewhere, but not sure exactly where?
10+
11+
![first image](./images/Everything.png)
12+
13+
## Listening?
14+
Gerev enables you to search your entire company from a single place.
15+
16+
## Made for devs
17+
### Find docs
18+
![second image](./images/product-example.png)
19+
20+
### Find Code
21+
![third image](./images/CodeCard.png)
22+
23+
### Troubleshoot Issues
24+
![fourth image](./images/sql-card.png)
625

726
## Integrations
827
- [x] Slack
928
- [x] Confluence
10-
- [x] Google Docs
29+
- [x] Google Drive
30+
- [ ] Gitlab Issues (In PR)
31+
- [ ] BookStack (In PR)
1132
- [ ] Notion (In Progress...)
12-
- [ ] Google Sheets (Coming Soon...)
13-
- [ ] Google Slides (Coming Soon...)
14-
- [ ] Google Calendar (Coming Soon...)
15-
33+
- [ ] Microsoft Teams
34+
- [ ] Sharepoint
35+
36+
### Natural Langauge
37+
Enables searching using natural language. such as `"How to do X"`, `"how to connect to Y"`, `"Do we support Z"`
1638

1739
## Installation
18-
19-
### Nvidia hardware
40+
1. Install *Nvidia for docker*
41+
2. Run docker
42+
43+
## Nvidia for docker
2044
Install nvidia container toolkit on the host machine.
2145

2246
```
@@ -32,11 +56,12 @@ sudo systemctl restart docker
3256
```
3357

3458

59+
## Run docker
3560
Then run the docker container like so:
3661

3762
### Nvidia hardware
3863
```bash
39-
sudo docker run --gpus all -p 80:80 -v ~/.gerev/storage:/opt/storage gerev/gerev
64+
docker run --gpus all -p 80:80 -v ~/.gerev/storage:/opt/storage gerev/gerev
4065
```
4166

4267
### CPU only (no GPU)

app/data_source_api/basic_document.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@ class DocumentType(Enum):
88
MESSAGE = "message"
99
COMMENT = "comment"
1010
PERSON = "person"
11+
GIT_ISSUE = "git_issue"
12+
GIT_PR = "git_pr"
13+
14+
15+
class FileType(Enum):
16+
GOOGLE_DOC = "doc"
17+
DOCX = "docx"
18+
PPTX = "pptx"
19+
TXT = "txt"
20+
21+
@classmethod
22+
def from_mime_type(cls, mime_type: str):
23+
if mime_type == 'application/vnd.google-apps.document':
24+
return cls.GOOGLE_DOC
25+
elif mime_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
26+
return cls.DOCX
27+
elif mime_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
28+
return cls.PPTX
29+
elif mime_type == 'text/plain':
30+
return cls.TXT
31+
else:
32+
return None
1133

1234

1335
@dataclass
@@ -22,4 +44,5 @@ class BasicDocument:
2244
author_image_url: str
2345
location: str
2446
url: str
47+
file_type: FileType = None
2548

app/data_sources/confluence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def validate_config(config: Dict) -> None:
4545
def __init__(self, *args, **kwargs):
4646
super().__init__(*args, **kwargs)
4747
confluence_config = ConfluenceConfig(**self._config)
48-
self._confluence = Confluence(url=confluence_config.url, token=confluence_config.token)
48+
self._confluence = Confluence(url=confluence_config.url, token=confluence_config.token, verify_ssl=False)
4949

5050
def _list_spaces(self) -> List[Dict]:
5151
return ConfluenceDataSource.list_spaces(confluence=self._confluence)

app/data_sources/gitlab.py

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,78 @@ class GitlabConfig(BaseModel):
2020

2121

2222
class GitlabDataSource(BaseDataSource):
23+
24+
def _parse_issues(self, documents: [], project_id: str, project_url: str):
25+
issues_url = f"{GITLAB_BASE_URL}/projects/{project_id}/issues"
26+
27+
issues_response = self._session.get(issues_url)
28+
issues_response.raise_for_status()
29+
issues_json = issues_response.json()
30+
31+
for issue in issues_json:
32+
last_modified = datetime.strptime(issue["updated_at"], "%Y-%m-%dT%H:%M:%S.%fZ")
33+
if last_modified < self._last_index_time:
34+
continue
35+
36+
documents.append(BasicDocument(
37+
id=issue["id"],
38+
data_source_id=self._data_source_id,
39+
type=DocumentType.GIT_ISSUE,
40+
title=issue['title'],
41+
content=issue["description"] if not None else "",
42+
author=issue['author']['name'],
43+
author_image_url=issue['author']['avatar_url'],
44+
location=project_url,
45+
url=issue['web_url'],
46+
timestamp=last_modified
47+
))
48+
49+
def _parse_pull_requests(self, documents: [], project_id: str, project_url: str):
50+
pull_requests_url = f"{GITLAB_BASE_URL}/projects/{project_id}/merge_requests"
51+
52+
pull_requests_response = self._session.get(pull_requests_url)
53+
pull_requests_response.raise_for_status()
54+
pull_requests_json = pull_requests_response.json()
55+
56+
for pull_request in pull_requests_json:
57+
last_modified = datetime.strptime(pull_request["updated_at"], "%Y-%m-%dT%H:%M:%S.%fZ")
58+
if last_modified < self._last_index_time:
59+
continue
60+
61+
documents.append(BasicDocument(
62+
id=pull_request["id"],
63+
data_source_id=self._data_source_id,
64+
type=DocumentType.GIT_PR,
65+
title=pull_request['title'],
66+
content=pull_request["description"] if not None else "",
67+
author=pull_request['author']['name'],
68+
author_image_url=pull_request['author']['avatar_url'],
69+
location=project_url,
70+
url=pull_request['web_url'],
71+
timestamp=last_modified
72+
))
73+
2374
@staticmethod
2475
def validate_config(config: Dict) -> None:
2576
try:
2677
parsed_config = GitlabConfig(**config)
2778
session = requests.Session()
2879
session.headers.update({"PRIVATE-TOKEN": parsed_config.access_token})
2980
projects_response = session.get(PROJECTS_URL)
30-
if projects_response.status_code != 200:
31-
raise ValueError("Invalid api key")
81+
projects_response.raise_for_status()
3282
except (KeyError, ValueError) as e:
3383
raise InvalidDataSourceConfig from e
3484

3585
def __init__(self, *args, **kwargs):
3686
super().__init__(*args, **kwargs)
3787
# Create a access token with sufficient permissions in https://gitlab.com/-/profile/personal_access_tokens
3888
self.gitlab_config = GitlabConfig(**self._config)
39-
self.session = requests.Session()
40-
self.session.headers.update({"PRIVATE-TOKEN": self.gitlab_config.access_token})
89+
self._session = requests.Session()
90+
self._session.headers.update({"PRIVATE-TOKEN": self.gitlab_config.access_token})
4191

4292
def _feed_new_documents(self) -> None:
43-
projects_response = self.session.get(PROJECTS_URL)
93+
projects_response = self._session.get(PROJECTS_URL)
94+
projects_response.raise_for_status()
4495
projects = projects_response.json()
4596

4697
self._parse_projects_in_parallel(projects)
@@ -51,49 +102,9 @@ def _parse_projects_worker(self, projects):
51102

52103
for project in projects:
53104
project_id = project["id"]
54-
issues_url = f"{GITLAB_BASE_URL}/projects/{project_id}/issues"
55-
issues_response = self.session.get(issues_url)
56-
issues_json = issues_response.json()
57-
58-
for issue in issues_json:
59-
last_modified = datetime.strptime(issue["updated_at"], "%Y-%m-%dT%H:%M:%S.%fZ")
60-
if last_modified < self._last_index_time:
61-
continue
62-
63-
documents.append(BasicDocument(
64-
id=issue["id"],
65-
data_source_id=self._data_source_id,
66-
type=DocumentType.DOCUMENT,
67-
title=issue['title'],
68-
content=issue["description"] if not None else "",
69-
author=issue['author']['name'],
70-
author_image_url=issue['author']['avatar_url'],
71-
location=project["web_url"],
72-
url=issue['web_url'],
73-
timestamp=last_modified
74-
))
75-
76-
pull_requests_url = f"{GITLAB_BASE_URL}/projects/{project_id}/merge_requests"
77-
pull_requests_response = self.session.get(pull_requests_url)
78-
pull_requests_json = pull_requests_response.json()
79-
80-
for pull_request in pull_requests_json:
81-
last_modified = datetime.strptime(pull_request["updated_at"], "%Y-%m-%dT%H:%M:%S.%fZ")
82-
if last_modified < self._last_index_time:
83-
continue
84-
85-
documents.append(BasicDocument(
86-
id=pull_request["id"],
87-
data_source_id=self._data_source_id,
88-
type=DocumentType.DOCUMENT,
89-
title=pull_request['title'],
90-
content=pull_request["description"] if not None else "",
91-
author=pull_request['author']['name'],
92-
author_image_url=pull_request['author']['avatar_url'],
93-
location=project["web_url"],
94-
url=pull_request['web_url'],
95-
timestamp=last_modified
96-
))
105+
project_url = project["web_url"]
106+
self._parse_issues(documents, project_id, project_url)
107+
self._parse_pull_requests(documents, project_id, project_url)
97108

98109
IndexingQueue.get().feed(documents)
99110

0 commit comments

Comments
 (0)