Compare commits

..

No commits in common. "b6ff7deed26f43c41384dc287fd0e8074262010e" and "fcb2a05a4778ca4592130558cff7553218f8a2d7" have entirely different histories.

11 changed files with 136 additions and 284 deletions

View File

@ -1,7 +1,7 @@
const globals = {
data_path: '/path/to/data'
data_path: '/var/www/csdbng/data'
}
module.exports = { globals }

View File

@ -10,8 +10,7 @@
"author": "Jaime Idolpx",
"license": "MIT",
"dependencies": {
"apollo-server": "^3.13.0",
"graphql": "^16.5.0",
"mariadb": "^3.3.2"
"apollo-server": "^3.7.0",
"graphql": "^16.5.0"
}
}

View File

@ -1,11 +1,10 @@
let globals = require('../config.js').globals;
let globals = require('../globals.js').globals;
const resolvers = {
Query: {
bbs: (parent, { id }, context, info) => getBBS(id),
bbss: (parent, { id }, context, info) => getBBSs(id),
getBBS: (parent, { id }, context, info) => getBBS(id),
},
Mutation: {
@ -18,35 +17,24 @@ const resolvers = {
//////////
BBS: {
Groups: ({ GroupIDs }, args, context, info) => getGroups(GroupIDs),
Handles: ({ HandleIDs }, args, context, info) => getHandles(HandleIDs),
GroupIDs: ({ GroupIDs }, args, context, info) => addGroups(GroupIDs, context),
UserHandleIDs: ({ UserHandleIDs }, args, context, info) => addHandles(UserHandleIDs, context),
Groups: (parent, args, context, info) => context.Groups,
Handles: (parent, args, context, info) => context.Handles,
},
BBSSysop: {
Handle: ({ HandleID }, args, context, info) => getHandle(HandleID),
HandleID: ({ HandleID }, args, context, info) => addHandle(HandleID, context),
},
}
getBBSFile = id => `${globals.data_path}/bbs/${Math.floor(id/1000)}/${id}/bbs.${id}.json`;
getBBSFile = id => `${globals.data_path}/bbs/${id}/bbs.${id}.json`;
// Object loader
getBBS = id => {
return loadJSON(getBBSFile(id));
}
getBBSs = idArray => {
data = [];
try {
idArray.forEach( id => {
// Add object
data.push(getBBS(id));
})
}
catch(err) {
//console.log(err);
}
return data;
}
// Load object by ID or ID array
addBBS = (id, context) => {

View File

@ -1,11 +1,10 @@
let globals = require('../config.js').globals;
let globals = require('../globals.js').globals;
const resolvers = {
Query: {
event: (parent, { id }, context, info) => getEvent(id),
events: (parent, { id }, context, info) => getEvents(id),
getEvent: (parent, { id }, context, info) => getEvent(id),
},
Mutation: {
@ -18,44 +17,32 @@ const resolvers = {
//////////
Event: {
// Releases: (parent, args, context, info) => context.Releases,
Releases: (parent, args, context, info) => context.Releases,
Groups: (parent, args, context, info) => context.Groups,
Handles: (parent, args, context, info) => context.Handles,
},
EventCompo: {
Releases: ({ ReleaseIDs }, args, context, info) => getReleases(ReleaseIDs),
ReleaseIDs: ({ ReleaseIDs }, args, context, info) => addReleases(ReleaseIDs, context),
},
EventReport: {
Handle: ({ HandleID }, args, context, info) => getHandle(HandleID),
HandleID: ({ HandleID }, args, context, info) => addHandle(HandleID, context),
},
EventComment: {
Handle: ({ HandleID }, args, context, info) => getHandle(HandleID),
HandleID: ({ HandleID }, args, context, info) => addHandle(HandleID, context),
},
EventOrganizers: {
Groups: ({ GroupIDs }, args, context, info) => getGroups(GroupIDs),
Handles: ({ HandleIDs }, args, context, info) => getHandles(HandleIDs),
GroupIDs: ({ GroupIDs }, args, context, info) => addGroups(GroupIDs, context),
HandleIDs: ({ HandleIDs }, args, context, info) => addHandles(HandleIDs, context),
},
}
getEventFile = id => `${globals.data_path}/event/${Math.floor(id/1000)}/${id}/event.${id}.json`;
getEventFile = id => `${globals.data_path}/event/${id}/event.${id}.json`;
// Object loader
getEvent = id => {
return loadJSON(getEventFile(id));
}
getEvents = idArray => {
data = [];
try {
idArray.forEach( id => {
// Add object
data.push(getEvent(id));
})
}
catch(err) {
//console.log(err);
}
return data;
}
// Load object by ID or ID array
addEvent = (id, context) => {

View File

@ -1,11 +1,10 @@
let globals = require('../config.js').globals;
let globals = require('../globals.js').globals;
const resolvers = {
Query: {
group: (parent, { id }, context, info) => getGroup(id),
groups: (parent, { id }, context, info) => getGroups(id),
getGroup: (parent, { id }, context, info) => getGroup(id),
},
Mutation: {
@ -18,43 +17,32 @@ const resolvers = {
//////////
Group: {
FounderHandles: ({ FounderHandleIDs }, args, context, info) => getHandles(FounderHandleIDs),
OrganizedEvents: ({ OrganizedEventIDs }, args, context, info) => getEvents(OrganizedEventIDs),
ReleaseIDs: ({ ReleaseIDs }, args, context, info) => addReleases(ReleaseIDs, context),
FounderHandleIDs: ({ FounderHandleIDs }, args, context, info) => addHandles(FounderHandleIDs, context),
OrganizedEventIDs: ({ OrganizedEventIDs }, args, context, info) => addEvents(OrganizedEventIDs, context),
BBSIDs: ({ BBSIDs }, args, context, info) => addBBSs(BBSIDs, context),
Releases: ({ ReleaseIDs }, args, context, info) => getReleases(ReleaseIDs),
BBSs: ({ BBSIDs }, args, context, info) => getBBSs(BBSIDs),
CoOpGroups: ({ CoOpGroupIDs }, args, context, info) => getGroups(CoOpGroupIDs),
Releases: (parent, args, context, info) => context.Releases,
Sceners: (parent, args, context, info) => context.Sceners,
Handles: (parent, args, context, info) => context.Handles,
Events: (parent, args, context, info) => context.Events,
BBSs: (parent, args, context, info) => context.BBSs,
},
GroupCommentData: {
Handle: ({ HandleID }, args, context, info) => getHandle(HandleID),
ScenerID: ({ ScenerID }, args, context, info) => addScener(ScenerID, context),
},
GroupMember: {
Handle: ({ HandleID }, args, context, info) => getHandle(HandleID),
HandleID: ({ HandleID }, args, context, info) => addHandle(HandleID, context),
},
}
getGroupFile = id => `${globals.data_path}/group/${Math.floor(id/1000)}/${id}/group.${id}.json`;
getGroupFile = id => `${globals.data_path}/group/${id}/group.${id}.json`;
// Object loader
getGroup = id => {
return loadJSON(getGroupFile(id));
}
getGroups = idArray => {
data = [];
try {
idArray.forEach( id => {
// Add object
data.push(getGroup(id));
})
}
catch(err) {
//console.log(err);
}
return data;
}
// Load object by ID or ID array
addGroup = (id, context) => {
@ -62,7 +50,6 @@ addGroup = (id, context) => {
return id;
}
addGroups = (idArray, context) => {
console.log(idArray);
try {
idArray.forEach( id => {
// Add object if it isn't already added
@ -73,7 +60,7 @@ addGroups = (idArray, context) => {
})
}
catch(err) {
console.log(err);
// console.log(err);
}
return idArray;

View File

@ -1,11 +1,10 @@
let globals = require('../config.js').globals;
let globals = require('../globals.js').globals;
const resolvers = {
Query: {
handle: (parent, { id }, context, info) => getHandle(id),
handles: (parent, { id }, context, info) => getHandles(id),
getHandle: (parent, { id }, context, info) => getHandle(id),
},
Mutation: {
@ -18,47 +17,31 @@ const resolvers = {
//////////
Handle: {
FoundedGroups: ({ FoundedGroupIDs }, args, context, info) => getGroups(FoundedGroupIDs),
MemberGroups: ({ MemberGroupIDs }, args, context, info) => getGroups(MemberGroupIDs),
OrganizedEvents: ({ OrganizedGroupIDs }, args, context, info) => getGroups(OrganizedGroupIDs),
AttendedEvents: ({ AttendedEventIDs }, args, context, info) => getEvents(AttendedEventIDs),
FoundedGroupIDs: ({ FoundedGroupIDs }, args, context, info) => addGroups(FoundedGroupIDs, context),
OrganizedEventIDs: ({ OrganizedEventIDs }, args, context, info) => addEvents(OrganizedEventIDs, context),
AttendedEventIDs: ({ AttendedEventIDs }, args, context, info) => addEvents(AttendedEventIDs, context),
ScenerIDs: ({ ScenerIDs }, args, context, info) => addSceners(ScenerIDs, context),
BBSSysop: ({ BBSSysopIDs }, args, context, info) => getBBSs(BBSSysopIDs),
BBSUser: ({ BBSUserIDs }, args, context, info) => getBBSs(BBSUserIDs),
Releases: ({ ReleaseIDs }, args, context, info) => getReleases(ReleaseIDs),
Sceners: ({ ScenerIDs }, args, context, info) => getSceners(ScenerIDs),
Releases: (parent, args, context, info) => context.Releases,
Groups: (parent, args, context, info) => context.Groups,
Sceners: (parent, args, context, info) => context.Sceners,
Events: (parent, args, context, info) => context.Events,
},
HandleGroup: {
Group: ({ GroupID }, args, context, info) => getGroup(GroupID),
GroupID: ({ GroupID }, args, context, info) => addGroup(GroupID, context),
},
HandleCredit: {
Releases: ({ ReleaseIDs }, args, context, info) => getReleases(ReleaseIDs),
ReleaseID: ({ ReleaseID }, args, context, info) => addRelease(ReleaseID, context),
},
}
getHandleFile = id => `${globals.data_path}/handle/${Math.floor(id/1000)}/${id}/handle.${id}.json`;
getHandleFile = id => `${globals.data_path}/handle/${id}/handle.${id}.json`;
// Object loader
getHandle = id => {
return loadJSON(getHandleFile(id));
}
getHandles = idArray => {
console.log(idArray)
data = [];
try {
idArray.forEach( id => {
// Add object
data.push(getHandle(id));
})
}
catch(err) {
//console.log(err);
}
return data;
}
// Load object by ID or ID array
addHandle = (id, context) => {

View File

@ -45,7 +45,7 @@ loadJSON = filename => {
if ( !fs.existsSync(filename) )
return null;
const data = fs.readFileSync(filename, {encoding:'utf8', flag:'r'});
if ( !data )
@ -64,7 +64,7 @@ addElementToObjectArray = (object, array, element) => {
} else {
// No - Create the array
object[array] = [element];
}
}
}
}
@ -86,4 +86,4 @@ objectExists = (object, array, id) => {
return found;
}
module.exports = { resolvers }
module.exports = { resolvers }

View File

@ -1,11 +1,10 @@
let globals = require('../config.js').globals;
let globals = require('../globals.js').globals;
const resolvers = {
Query: {
release: (parent, { id }, context, info) => getRelease(id),
releases: (parent, { id }, context, info) => getReleases(id),
getRelease: (parent, { id }, context, info) => getRelease(id),
},
Mutation: {
@ -18,42 +17,34 @@ const resolvers = {
//////////
Release: {
ReleasedAtEvent: ({ ReleasedAt }, args, context, info) => getEvent(ReleasedAt),
SIDs: ({ SIDIDs }, args, context, info) => getSIDs(SIDIDs),
ReleasedAt: ({ ReleasedAt }, args, context, info) => addEvent(ReleasedAt, context),
SIDIDs: ({ SIDIDs }, args, context, info) => addSIDs(SIDIDs, context),
Groups: (parent, args, context, info) => context.Groups,
Sceners: (parent, args, context, info) => context.Sceners,
Handles: (parent, args, context, info) => context.Handles,
Events: (parent, args, context, info) => context.Events,
SIDs: (parent, args, context, info) => context.SIDs,
},
ReleaseGroupsHandles: {
Groups: ({ GroupIDs }, args, context, info) => getGroups(GroupIDs),
Handles: ({ HandleIDs }, args, context, info) => getHandles(HandleIDs),
GroupIDs: ({ GroupIDs }, args, context, info) => addGroups(GroupIDs, context),
HandleIDs: ({ HandleIDs }, args, context, info) => addHandles(HandleIDs, context),
},
ReleaseCredit: {
Handles: ({ HandleIDs }, args, context, info) => getHandles(HandleIDs),
},
HandleID: ({ HandleID }, args, context, info) => addHandle(HandleID, context),
},
ReleaseCommentData: {
Handle: ({ HandleID }, args, context, info) => getHandle(HandleID),
ScenerID: ({ ScenerID }, args, context, info) => addScener(ScenerID, context),
},
}
getReleaseFile = id => `${globals.data_path}/release/${Math.floor(id/1000)}/${id}/release.${id}.json`;
getReleaseFile = id => `${globals.data_path}/release/${id}/release.${id}.json`;
// Object loader
getRelease = id => {
return loadJSON(getReleaseFile(id));
}
getReleases = idArray => {
data = [];
try {
idArray.forEach( id => {
// Add object
data.push(getRelease(id));
})
}
catch(err) {
console.log(err);
}
return data;
}
// Load object by ID or ID array
addRelease = (id, context) => {
@ -71,7 +62,7 @@ addReleases = (idArray, context) => {
})
}
catch(err) {
console.log(err);
// console.log(err);
}
return idArray;

View File

@ -1,11 +1,10 @@
let globals = require('../config.js').globals;
let globals = require('../globals.js').globals;
const resolvers = {
Query: {
scener: (parent, { id }, context, info) => getScener(id),
sceners: (parent, { id }, context, info) => getSceners(id),
getScener: (parent, { id }, context, info) => getScener(id),
},
Mutation: {
@ -18,31 +17,18 @@ const resolvers = {
//////////
Scener: {
Handles: ({ HandleIDs }, args, context, info) => getHandles(HandleIDs),
HandleIDs: ({ HandleIDs }, args, context, info) => addHandles(HandleIDs, context),
Handles: (parent, args, context, info) => context.Handles,
},
}
getScenerFile = id => `${globals.data_path}/scener/${Math.floor(id/1000)}/${id}/scener.${id}.json`;
getScenerFile = id => `${globals.data_path}/scener/${id}/scener.${id}.json`;
// Object loader
getScener = id => {
return loadJSON(getScenerFile(id));
}
getSceners = idArray => {
data = [];
try {
idArray.forEach( id => {
// Add object
data.push(getScener(id));
})
}
catch(err) {
//console.log(err);
}
return data;
}
// Load object by ID or ID array
addScener = (id, context) => {

View File

@ -1,11 +1,10 @@
let globals = require('../config.js').globals;
let globals = require('../globals.js').globals;
const resolvers = {
Query: {
sid: (parent, { id }, context, info) => getSID(id),
sids: (parent, { id }, context, info) => getSIDs(id),
getSID: (parent, { id }, context, info) => getSID(id),
},
Mutation: {
@ -18,31 +17,19 @@ const resolvers = {
//////////
SID: {
Releases: ({ ReleaseIDs }, args, context, info) => getReleases(ReleaseIDs),
ReleaseIDs: ({ ReleaseIDs }, args, context, info) => addReleases(ReleaseIDs, context),
Releases: (parent, args, context, info) => context.Releases,
}
}
getSIDFile = id => `${globals.data_path}/sid/${Math.floor(id/1000)}/${id}/sid.${id}.json`;
getSIDFile = id => `${globals.data_path}/sid/${id}/sid.${id}.json`;
// Object loader
getSID = id => {
return loadJSON(getSIDFile(id));
}
getSIDs = idArray => {
data = [];
try {
idArray.forEach( id => {
// Add object
data.push(getSID(id));
})
}
catch(err) {
//console.log(err);
}
return data;
}
// Load object by ID or ID array
addSID = (id, context) => {

View File

@ -17,7 +17,6 @@ type User {
MaintainerOf: UserRecords
# Enhanced Data
uuid: String
dateCreated: String
dateUpdated: String
@ -36,36 +35,37 @@ type UserRecords {
}
type Release {
ID: Int!
Name: String!
AKA: String
Type: String # should go in tag
GfxType: String # should go in tag
Type: String
GfxType: String
Rating: Float
ReleaseDate: [FuzzyDate]
ReleasedAt: Int
ReleasedAtEvent: Event
Achievement: ReleaseAchievement
ReleasedBy: ReleaseGroupsHandles
Credits: [ReleaseCredit]
Website: String
ScreenShot: [String]
ScreenShot: String
DownloadLinks: [ReleaseDownload]
OtherLinks: [ReleaseLink]
Comments: [ReleaseComment]
SIDIDs: [Int]
SIDs: [SID]
# Enhanced Data
Groups: [Group]
Sceners: [Scener]
Handles: [Handle]
Events: [Event]
SIDs: [SID]
Tags: [String]
uuid: String
tags: [String]
dateCreated: String
dateUpdated: String
deleted: Boolean
@ -79,15 +79,12 @@ type ReleaseAchievement {
type ReleaseGroupsHandles {
GroupIDs: [Int]
Groups: [Group]
HandleIDs: [Int]
Handles: [Handle]
}
type ReleaseCredit {
CreditType: String!
HandleIDs: [Int]
Handles: [Handle]
HandleID: Int!
}
type ReleaseLink {
@ -103,13 +100,13 @@ type ReleaseDownload {
Filename: String
Link: String!
Status: String
hash: String
crc32: String
}
type ReleaseComment {
Summary: [ReleaseCommentData]
Trivia: [ReleaseCommentData]
Goof: [ReleaseCommentData]
Goofs: [ReleaseCommentData]
HiddenPart: [ReleaseCommentData]
ProductionNote: [ReleaseCommentData]
UserComment: [ReleaseCommentData]
@ -117,14 +114,11 @@ type ReleaseComment {
type ReleaseCommentData {
Date: Int!
HandleID: Int!
Handle: Handle
ScenerID: Int!
Text: String!
}
type Group {
ID: Int!
Name: String!
@ -133,6 +127,7 @@ type Group {
Rating: Float
Trivia: String
BaseCountry: String
IsCoOp: Boolean
FoundDate: [FuzzyDate]
DissolveDate: [FuzzyDate]
@ -140,26 +135,22 @@ type Group {
Website: String
Grouptypes: [String]
Slogan: [String]
FounderHandleIDs: [Int]
FounderHandles: [Handle]
OrganizedEventIDs: [Int]
OrganizedEvents: [Event]
Members: [GroupMember]
ReleaseIDs: [Int]
Releases: [Release]
BBSIDs: [Int]
BBSs: [BBS]
UserComment: [GroupCommentData]
# Enhanced Data
CoOpGroupIDs: [Int]
CoOpGroups: [Group]
ReleaseIDs: [Int]
Members: [GroupMember]
FounderHandleIDs: [Int]
OrganizedEventIDs: [Int]
BBSIDs: [Int]
Releases: [Release]
Sceners: [Scener]
Handles: [Handle]
Events: [Event]
BBSs: [BBS]
Tags: [String]
uuid: String
tags: [String]
dateCreated: String
dateUpdated: String
deleted: Boolean
@ -168,14 +159,13 @@ type Group {
type GroupCommentData {
Date: Int!
HandleID: Int!
Handle: Handle
ScenerID: Int!
Text: String!
}
type GroupMember {
HandleID: Int!
Handle: Handle
GroupID: Int
HandleID: Int
Profession: [String]
JoinDate: [FuzzyDate]
@ -185,8 +175,6 @@ type GroupMember {
}
type Scener {
ID: Int!
RegisterdDate: String
@ -196,11 +184,10 @@ type Scener {
DeathDate: [FuzzyDate]
HandleIDs: [Int]
Handles: [Handle]
# Enhanced Data
uuid: String
tags: [String]
dateCreated: String
dateUpdated: String
deleted: Boolean
@ -208,8 +195,6 @@ type Scener {
}
type Handle {
ID: Int!
Handle: String!
@ -220,28 +205,16 @@ type Handle {
Credits: [HandleCredit]
FoundedGroupIDs: [Int]
FoundedGroups: [Group]
MemberGroupIDs: [Int]
MemberGroups: [Group]
OrganizedEventIDs: [Int]
OrganizedEvents: [Event]
AttendedEventIDs: [Int]
AttendedEvents: [Event]
BBSSysopIDs: [Int]
BBSSysop: [BBS]
BBSUserIDs: [Int]
BBSUser: [BBS]
ReleaseIDs: [Int]
Releases: [Release]
ScenerIDs: [Int]
Sceners: [Scener]
# Enhanced Data
Releases: [Release]
Groups: [Group]
Sceners: [Scener]
Events: [Event]
uuid: String
tags: [String]
dateCreated: String
dateUpdated: String
deleted: Boolean
@ -251,18 +224,14 @@ type Handle {
type HandleGroup {
GroupID: Int!
MemberStats: GroupMember
Group: Group
}
type HandleCredit {
CreditType: String!
ReleaseIDs: [Int]
Releases: [Release]
ReleaseID: Int!
}
type Event {
ID: Int!
Name: String!
@ -280,14 +249,17 @@ type Event {
Country: String
Website: String
Organizers: EventOrganizers
OrganizerGroup: Group
Compo: [EventCompo]
PartyReport: [EventReport]
UserComment: [EventComment]
Organizers: EventOrganizers
Releases: [Release]
Groups: [Group]
Handles: [Handle]
# Enhanced Data
uuid: String
tags: [String]
dateCreated: String
dateUpdated: String
deleted: Boolean
@ -297,7 +269,6 @@ type Event {
type EventCompo {
Type: String
ReleaseIDs: [Int]
Releases: [Release]
}
type EventReport {
@ -306,26 +277,19 @@ type EventReport {
Date: Int
Headline: String
Text: String
Handle: Handle
}
type EventComment {
HandleID: Int!
Date: Int!
Text: String!
Handle: Handle
}
type EventOrganizers {
GroupIDs: [Int]
Groups: [Group]
HandleIDs: [Int]
Handles: [Handle]
}
type BBS {
ID: Int!
Name: String!
@ -343,13 +307,12 @@ type BBS {
Status: String
GroupIDs: [Int]
UserHandleIDs: [Int]
Groups: [Group]
HandleIDs: [Int]
Handles: [Handle]
# Enhanced Data
uuid: String
tags: [String]
dateCreated: String
dateUpdated: String
deleted: Boolean
@ -364,12 +327,9 @@ type BBSOnlinePeriod {
type BBSSysop {
Type: String
HandleID: Int
Handle: Handle
}
type SID {
ID: Int!
HVSCPath: String
@ -386,11 +346,10 @@ type SID {
DataSize: Int
ReleaseIDs: [Int]
Releases: [Release]
# Enhanced Data
uuid: String
tags: [String]
dateCreated: String
dateUpdated: String
deleted: Boolean
@ -398,29 +357,14 @@ type SID {
}
type Query {
release(id: Int!) : Release
releases(id: [Int]!) : [Release]
group(id: Int!) : Group
groups(id: [Int]!) : [Group]
scener(id: Int!) : Scener
sceners(id: [Int]!) : [Scener]
handle(id: Int!) : Handle
handles(id: [Int]!) : [Handle]
event(id: Int!) : Event
events(id: [Int]!) : [Event]
bbs(id: Int!) : BBS
bbss(id: [Int]!) : [BBS]
sid(id: Int!) : SID
sids(id: [Int]!) : [SID]
getRelease(id: Int!) : Release
getGroup(id: Int!) : Group
getScener(id: Int!) : Scener
getHandle(id: Int!) : Handle
getEvent(id: Int!) : Event
getBBS(id: Int!) : BBS
getSID(id: Int!) : SID
}
type Mutation {
@ -447,4 +391,4 @@ type Mutation {
deleteEvent(id: Int!) : Event
deleteBBS(id: Int!) : BBS
deleteSID(id: Int!) : SID
}
}