Fixed db table names.

This commit is contained in:
mike.rode
2019-02-24 00:04:43 -06:00
parent ce42528377
commit 6bd9d474fc
37 changed files with 329 additions and 218 deletions
+2 -1
View File
@@ -1,7 +1,8 @@
module.exports = (sequelize, DataTypes) => {
const PlexLibrary = sequelize.define(
'plexlibrary',
'PlexLibrary',
{
title: DataTypes.STRING,
type: DataTypes.STRING,
views: DataTypes.INTEGER,
rating_key: DataTypes.INTEGER,
+2 -3
View File
@@ -1,6 +1,6 @@
module.exports = (sequelize, DataTypes) => {
const PlexSection = sequelize.define(
'plexsection',
'PlexSection',
{
title: DataTypes.STRING,
type: DataTypes.STRING,
@@ -9,8 +9,7 @@ module.exports = (sequelize, DataTypes) => {
{},
);
PlexSection.associate = function(models) {
console.log(models);
PlexSection.belongsTo(models.user);
PlexSection.belongsTo(models.User);
};
return PlexSection;
};
+2 -2
View File
@@ -1,6 +1,6 @@
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define(
'user',
'User',
{
firstName: DataTypes.STRING,
lastName: DataTypes.STRING,
@@ -9,7 +9,7 @@ module.exports = (sequelize, DataTypes) => {
{},
);
User.associate = function(models) {
User.hasMany(models.plexsection);
User.hasMany(models.PlexSection);
};
return User;
};
+1 -5
View File
@@ -1,8 +1,7 @@
import plexApiClient from './plexApi';
import plexApi from './plexApi';
import models from '../../models';
const importSections = async () => {
const plexApi = plexApiClient();
const sections = await plexApi.getSections();
createSections(sections);
return sections;
@@ -20,7 +19,6 @@ const createSections = sections => {
};
const importLibraries = async () => {
const plexApi = plexApiClient();
const sections = await plexApi.getSections();
sections.forEach(async section => {
await importLibrary(section.key);
@@ -28,7 +26,6 @@ const importLibraries = async () => {
};
const importMostWatched = async req => {
const plexApi = plexApiClient();
const mostWatched = await plexApi.getMostWatched(req);
mostWatched.forEach(async libraryData => {
await updateLibrary([libraryData]);
@@ -36,7 +33,6 @@ const importMostWatched = async req => {
};
const importLibrary = async sectionId => {
const plexApi = plexApiClient();
const libraryData = await plexApi.getLibraryDataBySection({
sectionId,
});