Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ChannelId from YTS Videos #179

Open
wants to merge 1 commit into
base: year-ap
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion DataLakeModels/DataLakeYouTubeStudioContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) {

modelBuilder.Entity<Video>()
.HasKey(table => new {
table.ChannelId,
table.VideoId,
table.ValidityStart,
table.Metric,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace DataLakeModels.Migrations.DataLakeYouTubeStudio
{
public partial class RemoveChannelIdYTSVideo : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Videos",
schema: "youtube_studio_v1",
table: "Videos");

migrationBuilder.DropColumn(
name: "ChannelId",
schema: "youtube_studio_v1",
table: "Videos");

migrationBuilder.AlterColumn<DateTime>(
name: "UpdateDate",
schema: "youtube_studio_v1",
table: "Groups",
nullable: true,
oldClrType: typeof(DateTime));

migrationBuilder.AddPrimaryKey(
name: "PK_Videos",
schema: "youtube_studio_v1",
table: "Videos",
columns: new[] { "VideoId", "ValidityStart", "Metric", "EventDate" });
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Videos",
schema: "youtube_studio_v1",
table: "Videos");

migrationBuilder.AddColumn<string>(
name: "ChannelId",
schema: "youtube_studio_v1",
table: "Videos",
nullable: false,
defaultValue: "");

migrationBuilder.AlterColumn<DateTime>(
name: "UpdateDate",
schema: "youtube_studio_v1",
table: "Groups",
nullable: false,
oldClrType: typeof(DateTime),
oldNullable: true);

migrationBuilder.AddPrimaryKey(
name: "PK_Videos",
schema: "youtube_studio_v1",
table: "Videos",
columns: new[] { "ChannelId", "VideoId", "ValidityStart", "Metric", "EventDate" });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.Property<string>("Title");

b.Property<DateTime>("UpdateDate");
b.Property<DateTime?>("UpdateDate");

b.HasKey("GroupId");

Expand Down Expand Up @@ -60,8 +60,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)

modelBuilder.Entity("DataLakeModels.Models.YouTube.Studio.Video", b =>
{
b.Property<string>("ChannelId");

b.Property<string>("VideoId");

b.Property<DateTime>("ValidityStart");
Expand All @@ -75,7 +73,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.Property<double>("Value");

b.HasKey("ChannelId", "VideoId", "ValidityStart", "Metric", "EventDate");
b.HasKey("VideoId", "ValidityStart", "Metric", "EventDate");

b.ToTable("Videos");
});
Expand Down
7 changes: 1 addition & 6 deletions DataLakeModels/Models/YouTube/Studio/Video.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ public Video(
DateTime validityStart,
DateTime validityEnd,
DateTime eventDate,
string channelId,
string videoId,
string metric,
double value
) {
ValidityStart = validityStart;
ValidityEnd = validityEnd;
EventDate = eventDate;
ChannelId = channelId;
VideoId = videoId;
Metric = metric;
Value = value;
Expand All @@ -30,14 +28,12 @@ public Video() {}
public DateTime ValidityEnd { get; set; }
[Column(TypeName = "date")]
public DateTime EventDate { get; set; }
public string ChannelId { get; set; }
public string VideoId { get; set; }
public string Metric { get; set; }
public double Value { get; set; }

bool IEquatable<Video>.Equals(Video other) {
return ChannelId == other.ChannelId &&
VideoId == other.VideoId &&
return VideoId == other.VideoId &&
Metric == other.Metric &&
EventDate == other.EventDate &&
(
Expand All @@ -51,7 +47,6 @@ public override string ToString() {
ValidityStart: {ValidityStart},
ValidityEnd: {ValidityEnd},
EventDate: {EventDate},
ChannelId: {ChannelId},
VideoId: {VideoId},
Metric: {Metric},
Value: {Value}
Expand Down
1 change: 0 additions & 1 deletion Jobs.Fetcher.YouTubeStudio/Helpers/DbWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public static Video DTOToVideo(Video_DTO dto) {
ValidityStart = validityStart,
ValidityEnd = validityEnd,
EventDate = eventTime.ToUniversalTime().Date,
ChannelId = dto.ChannelId,
VideoId = dto.VideoId,
Metric = dto.Metric,
Value = dto.Value
Expand Down
1 change: 0 additions & 1 deletion Test/YouTubeStudioFetcherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ protected void DeleteAllVideos(DataLakeYouTubeStudioContext ctx) {
protected Func<Video, bool> FindDTO(Video_DTO videoDTO) {
return v =>
v.VideoId == videoDTO.VideoId
&& v.ChannelId == videoDTO.ChannelId
&& v.EventDate == DbWriter.EpochToDateTime(videoDTO.EventDate).ToUniversalTime().Date
&& v.Metric == videoDTO.Metric
&& v.Value == videoDTO.Value;
Expand Down