Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #92 from NewSpring/fix-promotions
Browse files Browse the repository at this point in the history
fix other content fetches for future entries
  • Loading branch information
James Baxley committed Jul 23, 2016
2 parents 0747953 + e7872bb commit 5777e65
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/expression-engine/models/content/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,19 @@ export class Content extends EE {
[ChannelTitles.model, "entry_date", "DESC"],
],
include: [
{ model: ChannelTitles.model, where: { status: { $or: ["open", "featured" ]} } },
{
model: ChannelTitles.model,
where: {
status: { $or: ["open", "featured" ]},
entry_date: { $lte: Sequelize.literal("UNIX_TIMESTAMP(NOW())") },
expiration_date: {
$or: [
{ $eq: 0 },
{ $gt: Sequelize.literal("UNIX_TIMESTAMP(NOW())") },
],
},
},
},
{ model: Channels.model, where: { channel_name: { $or: includeChannels }} },
{
model: TagEntries.model,
Expand All @@ -282,6 +294,7 @@ export class Content extends EE {
return x.slice(offset, limit + offset);
})
.then(this.getFromIds.bind(this))
.then((x: any[]) => x.filter(y => !!y))
;
}

Expand All @@ -297,6 +310,12 @@ export class Content extends EE {
channelTitle.entry_date = {
$lte: Sequelize.literal("UNIX_TIMESTAMP(NOW())"),
};
channelTitle.expiration_date = {
$or: [
{ $eq: 0 },
{ $gt: Sequelize.literal("UNIX_TIMESTAMP(NOW())") },
],
};

if (channelTitle.status === "open") channelTitle.status = { $or: ["open", "featured"] };
return await this.cache.get(this.cache.encode(query, this.__type), () => ChannelData.find({
Expand All @@ -314,6 +333,7 @@ export class Content extends EE {
})
, { ttl: 3600, cache: false })
.then(this.getFromIds.bind(this))
.then((x: any[]) => x.filter(y => !!y))
;
}

Expand Down

0 comments on commit 5777e65

Please sign in to comment.