Revision | 12 (tree) |
---|---|
Time | 2019-11-26 12:09:12 |
Author | derekwildstar |
Ajustes no esquema de banco de dados
Criação de um parâmetro adicional para filtrar pela quantidade de dias que a última publicação de um usuário possui e assim poder melhorar a qualidade dos usuários minerados
Exibição da data de publicação na lista de mídias do usuário
@@ -5,7 +5,7 @@ | ||
5 | 5 | DROP TABLE IF EXISTS user; |
6 | 6 | |
7 | 7 | CREATE TABLE user (id VARCHAR(20) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NOT NULL |
8 | - ,username VARCHAR(20) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NOT NULL | |
8 | + ,username VARCHAR(40) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NOT NULL | |
9 | 9 | ,realname VARCHAR(64) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NOT NULL |
10 | 10 | ,pictureurl VARCHAR(255) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NULL DEFAULT NULL |
11 | 11 | ,biography TEXT CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NULL |
@@ -35,6 +35,7 @@ | ||
35 | 35 | ,width SMALLINT(6) NOT NULL |
36 | 36 | ,height SMALLINT(6) NOT NULL |
37 | 37 | ,wasliked BIT(1) NOT NULL DEFAULT 0 |
38 | + ,publishedat DATETIME NOT NULL | |
38 | 39 | ,userid VARCHAR(20) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NOT NULL |
39 | 40 | ,PRIMARY KEY (id) |
40 | 41 | ,CONSTRAINT user_media_fk FOREIGN KEY (userid) REFERENCES user (id) ON UPDATE CASCADE ON DELETE CASCADE) ENGINE=INNODB CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI; |
\ No newline at end of file |
@@ -21,6 +21,7 @@ | ||
21 | 21 | ShortCode: String; |
22 | 22 | Width: Word; |
23 | 23 | Height: Word; |
24 | + PublishedAt: TDateTime; | |
24 | 25 | end; |
25 | 26 | |
26 | 27 | TMedias = array of TMedia; |
@@ -59,6 +60,8 @@ | ||
59 | 60 | FollowersRelation: TRelation; |
60 | 61 | MediaCount: Cardinal; |
61 | 62 | MediaRelation: TRelation; |
63 | + LastMediaAge: Cardinal; | |
64 | + LastMediaAgeRelation: TRelation; | |
62 | 65 | end; |
63 | 66 | |
64 | 67 | EInstagram = Exception; |
@@ -109,6 +112,7 @@ | ||
109 | 112 | ACTNAddUser: TAction; |
110 | 113 | FDMD: TFDPhysMySQLDriverLink; |
111 | 114 | FDSC: TFDScript; |
115 | + FDTAMediaspublishedat: TDateTimeField; | |
112 | 116 | procedure FDCOBeforeConnect(Sender: TObject); |
113 | 117 | procedure DoClearFlag(Sender: TField; var Text: string; DisplayText: Boolean); |
114 | 118 | procedure FDTAUserAfterScroll(DataSet: TDataSet); |
@@ -190,7 +194,7 @@ | ||
190 | 194 | KRK.Lib.Rtl.Win.WinInet.Utilities, Windows, WinInet, |
191 | 195 | KRK.Lib.RegExp.Utils, NetEncoding, System.RegularExpressionsCore, |
192 | 196 | UFORMPrincipal, jpeg, KRK.Lib.Vcl.Forms.FormBlender, UFORMAddUserParams, |
193 | - System.Generics.Collections, Math, UConfigurations; | |
197 | + System.Generics.Collections, Math, UConfigurations, DateUtils; | |
194 | 198 | |
195 | 199 | {%CLASSGROUP 'Vcl.Controls.TControl'} |
196 | 200 |
@@ -237,6 +241,7 @@ | ||
237 | 241 | FDTAMediasshortcode.AsString := ME.ShortCode; |
238 | 242 | FDTAMediaswidth.AsInteger := Me.Width; |
239 | 243 | FDTAMediasheight.AsInteger := ME.Height; |
244 | + FDTAMediaspublishedat.AsDateTime := ME.PublishedAt; | |
240 | 245 | FDTAMediasuserid.AsString := AInstagramUser.id; |
241 | 246 | FDTAMedias.Post; |
242 | 247 | end; |
@@ -856,7 +861,8 @@ | ||
856 | 861 | UseExtendedFilters := (AParams.FollowersCount > 0) |
857 | 862 | or (AParams.FollowingCount > 0) |
858 | 863 | or (AParams.MediaCount > 0) |
859 | - or (Byte(AParams.BusinessAccount) > 0); | |
864 | + or (Byte(AParams.BusinessAccount) > 0) | |
865 | + or (AParams.LastMediaAge > 0); | |
860 | 866 | |
861 | 867 | if AParams.UsersToRegister = 0 then |
862 | 868 | raise EInstagram.Create('Por favor informe a quantidade de usuários a registrar'); |
@@ -962,6 +968,27 @@ | ||
962 | 968 | end; |
963 | 969 | end; |
964 | 970 | |
971 | + if AParams.LastMediaAge > 0 then | |
972 | + begin | |
973 | + if Length(Followers[i].LastestMedia) > 0 then | |
974 | + case AParams.LastMediaAgeRelation of | |
975 | + rMoreThan: begin | |
976 | + // Se a idade da publicação da midia precisar ser maior que o parâmetro, mas for menor, pula | |
977 | + if Cardinal(DaysBetween(Now,Followers[i].LastestMedia[0].PublishedAt)) < AParams.LastMediaAge then | |
978 | + Continue; | |
979 | + end; | |
980 | + rLessThan: begin | |
981 | + // Se a idade da publicação da midia precisar ser menor que o parâmetro, mas for maior, pula | |
982 | + if Cardinal(DaysBetween(Now,Followers[i].LastestMedia[0].PublishedAt)) > AParams.LastMediaAge then | |
983 | + Continue; | |
984 | + end; | |
985 | + end | |
986 | + // Se o usuário não tem qualquer mídia, ou no caso dele ter um | |
987 | + // perfil privado que não está sendo seguido por nós, onde não é | |
988 | + // possível ver suas mídias, não há nada a fazer a não ser pular | |
989 | + else | |
990 | + Continue; | |
991 | + end; | |
965 | 992 | end; |
966 | 993 | |
967 | 994 | if AddUser(Followers[i],AUserId) then |
@@ -1156,6 +1183,8 @@ | ||
1156 | 1183 | GetValue<Cardinal>('width'); |
1157 | 1184 | AInstagramUser.LastestMedia[i].ShortCode := JA.Items[i].GetValue<TJSONObject>('node'). |
1158 | 1185 | GetValue<String>('shortcode'); |
1186 | + AInstagramUser.LastestMedia[i].PublishedAt := UnixToDateTime(JA.Items[i].GetValue<TJSONObject>('node'). | |
1187 | + GetValue<Cardinal>('taken_at_timestamp')); | |
1159 | 1188 | end; |
1160 | 1189 | end; |
1161 | 1190 | finally |
@@ -1284,6 +1313,7 @@ | ||
1284 | 1313 | FDTAMediasshortcode.AsString := ME.ShortCode; |
1285 | 1314 | FDTAMediaswidth.AsInteger := Me.Width; |
1286 | 1315 | FDTAMediasheight.AsInteger := ME.Height; |
1316 | + FDTAMediaspublishedat.AsDateTime := ME.PublishedAt; | |
1287 | 1317 | FDTAMediasuserid.AsString := AInstagramUser.id; |
1288 | 1318 | FDTAMedias.Post; |
1289 | 1319 | end; |
@@ -28,6 +28,9 @@ | ||
28 | 28 | CBBXMediaRelation: TComboBox; |
29 | 29 | EDITMediaCount: TEdit; |
30 | 30 | RAGRBusinessAccount: TRadioGroup; |
31 | + CBBXLastMediaAgeRelation: TComboBox; | |
32 | + LABELastMediaAge: TLabel; | |
33 | + EDITLastMediaAge: TEdit; | |
31 | 34 | procedure PNGBOKClick(Sender: TObject); |
32 | 35 | procedure FormCreate(Sender: TObject); |
33 | 36 | private |
@@ -86,6 +89,13 @@ | ||
86 | 89 | else |
87 | 90 | FAddFollowersParams.MediaRelation := rLessThan; |
88 | 91 | |
92 | + FAddFollowersParams.LastMediaAge := StrToIntDef(EDITLastMediaAge.Text,0); | |
93 | + | |
94 | + if CBBXLastMediaAgeRelation.ItemIndex = 0 then | |
95 | + FAddFollowersParams.LastMediaAgeRelation := rMoreThan | |
96 | + else | |
97 | + FAddFollowersParams.LastMediaAgeRelation := rLessThan; | |
98 | + | |
89 | 99 | FAddFollowersParams.BusinessAccount := TBusinessAccount(RAGRBusinessAccount.ItemIndex); |
90 | 100 | |
91 | 101 | ModalResult := mrOk; |