Skip to content

Commit

Permalink
Merge pull request #91 from KeithKelleher/master
Browse files Browse the repository at this point in the history
updates to support Pharos version 3.16
  • Loading branch information
KeithKelleher authored Apr 13, 2023
2 parents d0cd95f + 01e97f6 commit 8182661
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pharos-graphql-server",
"version": "3.15.1",
"version": "3.16.0",
"description": "",
"main": "src/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/db_credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//
const cred = {
DBHOST: 'tcrd-cluster.cluster-ceyknq0yekb3.us-east-1.rds.amazonaws.com',
DBNAME: 'tcrd6134pharos2',
DBNAME: 'pharos316',
USER: 'tcrd',
PWORD: '',
LASTMOD: '2023-01-13'
LASTMOD: '2023-03-30'
};
module.exports.cred = cred;
56 changes: 56 additions & 0 deletions src/models/databaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class DatabaseConfig {

modelList: Map<string, ModelInfo> = new Map<string, { name: string, table: string, column: string }>();
communityDataList: Map<string, any[]> = new Map<string, any[]>();
communityDataSequenceList: Map<string, any> = new Map<string, any>();
database: any;
dbName: string;
settingsDB: any;
Expand All @@ -143,6 +144,13 @@ export class DatabaseConfig {
return {community_data: 'community_data'};
}

get communitySequenceDataTables(): {community_sequence_data: string, community_sequence_tracks: string} {
return {
community_sequence_data: 'community_sequence_data',
community_sequence_tracks: 'community_sequence_tracks'
};
}

get assocModelTable(): { associated_model: string } {
return {associated_model: 'model'};
};
Expand Down Expand Up @@ -175,6 +183,54 @@ export class DatabaseConfig {
list.push(row);
});
});
const seqQuery = this.settingsDB({...this.communitySequenceDataTables})
.select({
code: 'code',
category_label: 'community_sequence_data.label',
category_type: 'community_sequence_data.trackType',
track_label: 'community_sequence_tracks.label',
instructions: 'community_sequence_tracks.instructions',
track_type: 'community_sequence_tracks.trackType',
adapter: 'community_sequence_tracks.adapter',
url: 'community_sequence_tracks.url',
tooltip: 'community_sequence_tracks.tooltip',
row: 'community_sequence_tracks.row',
filter: 'community_sequence_tracks.filter'
})
.whereRaw('community_sequence_tracks.sequence_category = community_sequence_data.code')
.where('community_sequence_data.default', true)
.then((rows: any[]) => {
rows.forEach(row => {
const appendTrack = (list: any[], currentRow: any) => {
list.push({
name: row.code + '-' + row.row,
row: row.row,
label: row.track_label,
instructions: row.instructions,
filter: JSON.parse(row.filter),
trackType: row.track_type,
data: [{
adapter: row.adapter,
url: row.url
}],
tooltip: row.tooltip
});
}
if (this.communityDataSequenceList.has(row.code)) {
const categoryObj = this.communityDataSequenceList.get(row.code);
appendTrack(categoryObj.tracks, row);
} else {
const categoryObj = {
name: row.code,
label: row.category_label,
trackType: row.category_type,
tracks: []
};
appendTrack(categoryObj.tracks, row);
this.communityDataSequenceList.set(row.code, categoryObj);
}
});
});
}
loadMondoMap() {
const query = this.database('mondo_xref').distinct({
Expand Down
Binary file modified src/pharos_config.sqlite
Binary file not shown.
Binary file modified src/unfiltered_counts.sqlite
Binary file not shown.
10 changes: 10 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ module.exports.applySpecialRoutes = (app, tcrd) => {
res.end(JSON.stringify(parseResidueData(results)));
});

app.get("/sources", async (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Access-Control-Allow-Origin', '*');
const list = [];
tcrd.tableInfo.communityDataSequenceList.forEach((v,k) => {
list.push(v);
})
res.end(JSON.stringify(list));
});

app.get("/sitemap.xml", async (req, res) => {
res.setHeader('Content-Type', 'application/xml');
res.setHeader('Access-Control-Allow-Origin', '*');
Expand Down

0 comments on commit 8182661

Please sign in to comment.