Skip to content

Commit

Permalink
Merge pull request #384 from digital-sustainability/logoDisplay
Browse files Browse the repository at this point in the history
Logo display
  • Loading branch information
holdan-8 committed Aug 22, 2024
2 parents 398a9fa + f2cd76b commit 7be8a1f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 266 deletions.
2 changes: 0 additions & 2 deletions oss-api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { join } from 'path';
import { GithubService } from './github/github.service';
import { LoggerModule } from 'nestjs-pino';
import { ScheduleModule } from '@nestjs/schedule';
import { TransformerService } from './transformer/transformer.service';
import { GithubCrawlerService } from './github-crawler/github-crawler.service';
import { DataService } from './data/data.service';
import { TelemetryService } from './telemetry/telemetry.service';
Expand All @@ -27,7 +26,6 @@ import { AuthModule } from './auth/auth.module';
providers: [
MongoDbService,
GithubService,
TransformerService,
GithubCrawlerService,
DataService,
TelemetryService,
Expand Down
13 changes: 12 additions & 1 deletion oss-api/src/data/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Contributor } from '../interfaces';
import { MongoDbService } from '../mongo-db/mongo-db.service';
import { v4 as uuidv4 } from 'uuid';
import { ObjectId } from 'mongodb';
import { Cron } from '@nestjs/schedule';
import { Cron, CronExpression } from '@nestjs/schedule';
import { RepoData } from '../interfaces';

@Injectable()
Expand Down Expand Up @@ -220,6 +220,17 @@ export class DataService {
const organisations = await this.mongo.findOrganisationsWithNames(
todoInstitution.orgs.map((organisation) => organisation.name),
);
// make sure the order of the organisations is the same as in the todoInstitution
organisations.sort((a, b) => {
const indexA = todoInstitution.orgs.findIndex(
(org) => org.name === a.name,
);
const indexB = todoInstitution.orgs.findIndex(
(org) => org.name === b.name,
);
return indexA - indexB;
});

const institution: InstitutionRevised = {
uuid: todoInstitution.uuid,
shortname: todoInstitution.shortname,
Expand Down
33 changes: 24 additions & 9 deletions oss-api/src/mongo-db/mongo-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,23 +843,38 @@ export class MongoDbService implements OnApplicationShutdown, OnModuleInit {
},
},
{
$set: {
orgs: '$orga',
$addFields: {
orgs: {
$map: {
input: '$orgs',
as: 'org_id',
in: {
$arrayElemAt: [
{
$filter: {
input: '$orga',
as: 'org',
cond: { $eq: ['$$org._id', '$$org_id'] },
},
},
0,
],
},
},
},
},
},
{ $unwind: { path: '$orga', preserveNullAndEmptyArrays: true } },
{
$lookup: {
from: 'repositoriesNew',
localField: 'orga.repos',
localField: 'orgs.repos',
foreignField: '_id',
as: 'repo',
},
},
{ $unwind: { path: '$repo', preserveNullAndEmptyArrays: true } },
//{ $sort: { 'orga.created_at': 1 } },
//is that sort really necessary if in the end the list of orgs
//is not sorted in the frontend?
{
$unwind: { path: '$repo', preserveNullAndEmptyArrays: true },
},
{
$group: {
_id: '$_id',
Expand All @@ -874,7 +889,7 @@ export class MongoDbService implements OnApplicationShutdown, OnModuleInit {
location: { $first: '$orga.locations' },
created_at: { $first: '$orga.created_at' },
stats: { $push: { $last: '$repo.stats' } },
orgs: { $first: '$orgs' },
orgs: { $first: '$orgs' }, // Ensure the order of orgs is maintained
},
},
{
Expand Down
18 changes: 0 additions & 18 deletions oss-api/src/transformer/transformer.service.spec.ts

This file was deleted.

236 changes: 0 additions & 236 deletions oss-api/src/transformer/transformer.service.ts

This file was deleted.

0 comments on commit 7be8a1f

Please sign in to comment.