Skip to content

Commit

Permalink
Merge branch 'main' into documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
holdan-8 committed Mar 6, 2024
2 parents 228a0bd + 49085a8 commit 1004581
Show file tree
Hide file tree
Showing 25 changed files with 1,085 additions and 160 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ jobs:
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
containerfiles: Dockerfile

15 changes: 15 additions & 0 deletions .github/workflows/validate_configs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Validate configuration files
on: [push, pull_request]

jobs:
validate-config:
runs-on: ubuntu-latest
steps:
- name: Check out sources
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11.5'
- name: Validate configuration files
run: python validate_github_repos.py
30 changes: 30 additions & 0 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ The institution blocks look like this:
}
```

**Generate V4 UUID:** https://www.uuidgenerator.net/version4

**Important:** oid as seen in [github_repos.json](/github_repos.json) will be created automaticly when updating the Database, so it doesn't need to be added by you.

**Important:**
sector needs to be one of these:
- FoodBeverage
- Gov_Companies
- Gov_Federal
- IT
- Communities
- Gov_Cities
- Gov_Cantons
- Media
- NGOs
- ResearchAndEducation
- Banking
- Others
- Insurances
- Pharma
- PolitcalParties

Just edit or append a new block to the file and make a pull request.

If everything is correct it will be added and updated on the website.

### What are ts and why are they set to null

ts are timestamps that are used to check when that organization/institution were crawled.

"null" is the intial value so that the new organization/institution will be crawled with the next crawl run.

After that it will be overwritte in the database.
40 changes: 30 additions & 10 deletions Dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,43 @@

### Env Variables

These are the env variables that need to be set-up (.env.sample file as template):
- MONGO_READ: The connection string
- MONGO_DATABASE: Which database to use
- GITHUB_TOKEN: The Github token
- LOG_PATH: The path for the log files to be saved in
- DATA_PATH: The path for the data files to be saved in
These are the env variables that need to be set-up (.env.sample file as template) (.env.sample file as template):
- MONGO_READ: The connection string. Can be found in Keepass
- MONGO_DATABASE: Which database to use. production or testingNew
- GITHUB_TOKEN: The Github token. Can be found in Keepass
- LOG_PATH: The path for the log files to be saved in. Somewhere on your system.
- DATA_PATH: The path for the data files to be saved in. Somewhere on your system.

### Run Backend

> - From root cd into */oss-api*</br>
> - Run npm i to install all the necessary packages
> - Finally you can start the dec server with **npm run start:dev**
> - Run **npm i** to install all the necessary packages
> - Finally you can start the dev server with **npm run start:dev**
## Frontend

**Pre-requirements:** AngularJS, npm, finished backend setup

> - From root cd into */frontend*</br>
> - Run npm i to install all the necessary packages</br>
> - Finally you can start the dev server with **npm run start**
> - Run **npm i** to install all the necessary packages</br>
> - Finally you can start the dev server with **npm run start**

# Update Institutions

Once someone has updated the github_repos.json file and the pull request was merged, the new or updated insitution must be added to the database.

This can be done in 4 easy steps:

1. Pull Repository
2. Enter the connection string, which can be found in Keepass, into the URI field of MongoCompass.

![MongoCompass Connection string](/assets/images/MongoConnection.png)

3. Choose the **production** DB and then todoInstitution collection.

![Mongo choose DB](/assets/images/MongoDB.png)

4. Press **Add Data -> Import file** and choose github_repos.json. Keep in mind that *Stop on errors* needs to be unchecked. Then just click *Import*.

![Add new Data to DB](/assets/images/AddData.png)
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 as backendBuild
FROM node:20.6.0-alpine3.17 as backendBuild
LABEL stage=build
ENV NODE_ENV=PRODUCTION

Expand All @@ -10,7 +10,7 @@ RUN npm install

RUN npm run build

FROM node:18 as frontendBuild
FROM node:20.6.0-alpine3.17 as frontendBuild
LABEL stage=build
ENV NODE_ENV=PRODUCTION

Expand All @@ -24,7 +24,7 @@ RUN npm install

RUN npm run build:prod

FROM node:18 as prod
FROM node:20.6.0-alpine3.17 as prod

COPY --from=backendBuild dist dist

Expand Down
Binary file added assets/images/AddData.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/MongoConnection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/MongoDB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions frontend/src/app/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ export class DataService {
return repoData;
}

async loadRepoDataDetailView(config: {
search?: string;
sort?: string;
direction?: 'ASC' | 'DESC';
page?: string;
count?: string;
includeForks?: string;
}) {
const repoData = await this.http
.get<{
repositories: Repository[];
total: number;
}>(`${environment.api}institutionRepositories`, {
params: config,
})
.toPromise();
return repoData;
}

async loadUserData(config: {
search: string;
sort: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,17 @@ export class InstitutionDetailViewComponent implements OnInit {
content: 'total_num_contributors',
toNiceName: false,
},
{
/*{
text: 'Own repositories forks:',
content: 'total_num_own_repo_forks',
toNiceName: false,
},
},*/
{
text: 'Forks in repositories:',
content: 'total_num_forks_in_repos',
toNiceName: false,
},
{ text: 'Commits:', content: 'total_num_commits', toNiceName: false },
{
text: 'Pull requests:',
content: 'total_pull_requests',
toNiceName: false,
},
{ text: 'Issues:', content: 'total_issues', toNiceName: false },
{ text: 'Stars:', content: 'total_num_stars', toNiceName: false },
{ text: 'Watchers:', content: 'total_num_watchers', toNiceName: false },
{
Expand All @@ -94,15 +88,15 @@ export class InstitutionDetailViewComponent implements OnInit {
},
{
text: 'Total pull requests:',
content: 'total_pull_requests_all',
content: 'total_pull_requests',
toNiceName: false,
},
{
text: 'Total closed pull requests:',
content: 'total_pull_requests_closed',
toNiceName: false,
},
{ text: 'Total issues:', content: 'total_issues_all', toNiceName: false },
{ text: 'Total issues:', content: 'total_issues', toNiceName: false },
{
text: 'Total closed issues:',
content: 'total_issues_closed',
Expand Down Expand Up @@ -265,7 +259,7 @@ export class InstitutionDetailViewComponent implements OnInit {

reloadData() {
this.dataService
.loadRepoData({
.loadRepoDataDetailView({
sort: this.activeSort,
direction: this.sortDirection,
page: this.page.toString(),
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/app/pipes/toNiceName.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Pipe, PipeTransform } from '@angular/core';
export class ToNiceNamePipe implements PipeTransform {
sectors: { original: string; nice: string }[] = [
{ original: 'ResearchAndEducation', nice: 'Research and education' },
{ original: 'FoodBeverage', nice: 'Food and Beverage' },
{ original: 'PolitcalParties', nice: 'Politcal Parties' },
{ original: 'NGOs', nice: 'NGOs' },
{ original: 'Media', nice: 'Media' },
{ original: 'Insurances', nice: 'Insurances' },
Expand All @@ -22,7 +24,7 @@ export class ToNiceNamePipe implements PipeTransform {
transform(value: any): string {
if (!value) return '';
const name: any = this.sectors.find(
(sector) => sector.original === value.toString()
(sector) => sector.original === value.toString(),
);
return name ? name.nice : value;
}
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/app/ranking/ranking.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ <h1>
<mat-option
*ngFor="let sectorObj of sectorFilters"
[value]="sectorObj.sector"
><span>{{ sectorObj.sector | toNiceName }}</span>
<span style="float: right">{{ sectorObj.count }}</span></mat-option
>
<div
style="
width: 136px;
display: flex;
align-items: center;
justify-content: space-between;
"
>
<span>{{ sectorObj.sector | toNiceName }}</span>
<span>{{ sectorObj.count }}</span>
</div>
</mat-option>
</mat-select>
</mat-form-field>
<mat-checkbox
Expand All @@ -56,6 +66,7 @@ <h1>
[dataSource]="dataSource"
class="mat-elevation-z8"
matSort
matSortStart="desc"
matSortActive="num_repos"
matSortDirection="desc"
(matSortChange)="sortingUpdate($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h1>Ranking of {{ numRepositories }} Repositories.</h1>
[dataSource]="dataSource"
class="mat-elevation-z8"
matSort
matSortStart="desc"
matSortActive="num_commits"
matSortDirection="desc"
(matSortChange)="sortingUpdate($event)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit, Inject } from '@angular/core';
import { lowerCase } from 'lodash-es';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';

@Component({
Expand All @@ -9,11 +8,11 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
})
export class RepositoryDetailViewComponent implements OnInit {
repositoryStats: object[] = [
{ text: 'Archived:', content: 'archived', toNiceName: true },
{ text: 'Institution:', content: 'institution_name_de', toNiceName: false },
{ text: 'Archived:', content: 'archived', toNiceName: false },
{ text: 'Institution:', content: 'institution', toNiceName: false },
{
text: 'Organization:',
content: 'organisation_name_de',
content: 'organization',
toNiceName: false,
},
{
Expand All @@ -28,7 +27,7 @@ export class RepositoryDetailViewComponent implements OnInit {
},
{
text: 'Commits last year:',
content: 'last_years_commits',
content: 'num_commits',
toNiceName: false,
},
// { text: 'License:', content: 'license', toNiceName: false },
Expand Down Expand Up @@ -70,7 +69,7 @@ export class RepositoryDetailViewComponent implements OnInit {

constructor(
private dialogRef: MatDialogRef<RepositoryDetailViewComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
@Inject(MAT_DIALOG_DATA) public data: any,
) {}

ngOnInit(): void {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/user-ranking/user-ranking.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h1>Ranking of {{ numUsers }} users.</h1>
[dataSource]="dataSource"
class="mat-elevation-z8"
matSort
matSortStart="desc"
matSortActive="last_years_commits"
matSortDirection="desc"
(matSortChange)="sortingUpdate($event)"
Expand Down
24 changes: 0 additions & 24 deletions githubRepoValidation.py

This file was deleted.

Loading

0 comments on commit 1004581

Please sign in to comment.