mirror of
https://github.com/mjrode/WhatToWatch.git
synced 2026-05-07 13:09:08 -05:00
Fixed db table names.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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,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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user