• R/O
  • SSH
  • HTTPS

instalikes: Commit


Commit MetaInfo

Revision12 (tree)
Zeit2019-11-26 12:09:12
Autorderekwildstar

Log Message

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

Ändern Zusammenfassung

Diff

--- trunk/dev/dba/InstaLikes.sql (revision 11)
+++ trunk/dev/dba/InstaLikes.sql (revision 12)
@@ -5,7 +5,7 @@
55 DROP TABLE IF EXISTS user;
66
77 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
99 ,realname VARCHAR(64) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NOT NULL
1010 ,pictureurl VARCHAR(255) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NULL DEFAULT NULL
1111 ,biography TEXT CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NULL
@@ -35,6 +35,7 @@
3535 ,width SMALLINT(6) NOT NULL
3636 ,height SMALLINT(6) NOT NULL
3737 ,wasliked BIT(1) NOT NULL DEFAULT 0
38+ ,publishedat DATETIME NOT NULL
3839 ,userid VARCHAR(20) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_UNICODE_CI NOT NULL
3940 ,PRIMARY KEY (id)
4041 ,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
--- trunk/src/UDAMOPrincipal.pas (revision 11)
+++ trunk/src/UDAMOPrincipal.pas (revision 12)
@@ -21,6 +21,7 @@
2121 ShortCode: String;
2222 Width: Word;
2323 Height: Word;
24+ PublishedAt: TDateTime;
2425 end;
2526
2627 TMedias = array of TMedia;
@@ -59,6 +60,8 @@
5960 FollowersRelation: TRelation;
6061 MediaCount: Cardinal;
6162 MediaRelation: TRelation;
63+ LastMediaAge: Cardinal;
64+ LastMediaAgeRelation: TRelation;
6265 end;
6366
6467 EInstagram = Exception;
@@ -109,6 +112,7 @@
109112 ACTNAddUser: TAction;
110113 FDMD: TFDPhysMySQLDriverLink;
111114 FDSC: TFDScript;
115+ FDTAMediaspublishedat: TDateTimeField;
112116 procedure FDCOBeforeConnect(Sender: TObject);
113117 procedure DoClearFlag(Sender: TField; var Text: string; DisplayText: Boolean);
114118 procedure FDTAUserAfterScroll(DataSet: TDataSet);
@@ -190,7 +194,7 @@
190194 KRK.Lib.Rtl.Win.WinInet.Utilities, Windows, WinInet,
191195 KRK.Lib.RegExp.Utils, NetEncoding, System.RegularExpressionsCore,
192196 UFORMPrincipal, jpeg, KRK.Lib.Vcl.Forms.FormBlender, UFORMAddUserParams,
193- System.Generics.Collections, Math, UConfigurations;
197+ System.Generics.Collections, Math, UConfigurations, DateUtils;
194198
195199 {%CLASSGROUP 'Vcl.Controls.TControl'}
196200
@@ -237,6 +241,7 @@
237241 FDTAMediasshortcode.AsString := ME.ShortCode;
238242 FDTAMediaswidth.AsInteger := Me.Width;
239243 FDTAMediasheight.AsInteger := ME.Height;
244+ FDTAMediaspublishedat.AsDateTime := ME.PublishedAt;
240245 FDTAMediasuserid.AsString := AInstagramUser.id;
241246 FDTAMedias.Post;
242247 end;
@@ -856,7 +861,8 @@
856861 UseExtendedFilters := (AParams.FollowersCount > 0)
857862 or (AParams.FollowingCount > 0)
858863 or (AParams.MediaCount > 0)
859- or (Byte(AParams.BusinessAccount) > 0);
864+ or (Byte(AParams.BusinessAccount) > 0)
865+ or (AParams.LastMediaAge > 0);
860866
861867 if AParams.UsersToRegister = 0 then
862868 raise EInstagram.Create('Por favor informe a quantidade de usuários a registrar');
@@ -962,6 +968,27 @@
962968 end;
963969 end;
964970
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;
965992 end;
966993
967994 if AddUser(Followers[i],AUserId) then
@@ -1156,6 +1183,8 @@
11561183 GetValue<Cardinal>('width');
11571184 AInstagramUser.LastestMedia[i].ShortCode := JA.Items[i].GetValue<TJSONObject>('node').
11581185 GetValue<String>('shortcode');
1186+ AInstagramUser.LastestMedia[i].PublishedAt := UnixToDateTime(JA.Items[i].GetValue<TJSONObject>('node').
1187+ GetValue<Cardinal>('taken_at_timestamp'));
11591188 end;
11601189 end;
11611190 finally
@@ -1284,6 +1313,7 @@
12841313 FDTAMediasshortcode.AsString := ME.ShortCode;
12851314 FDTAMediaswidth.AsInteger := Me.Width;
12861315 FDTAMediasheight.AsInteger := ME.Height;
1316+ FDTAMediaspublishedat.AsDateTime := ME.PublishedAt;
12871317 FDTAMediasuserid.AsString := AInstagramUser.id;
12881318 FDTAMedias.Post;
12891319 end;
--- trunk/src/UFORMAddUserParams.pas (revision 11)
+++ trunk/src/UFORMAddUserParams.pas (revision 12)
@@ -28,6 +28,9 @@
2828 CBBXMediaRelation: TComboBox;
2929 EDITMediaCount: TEdit;
3030 RAGRBusinessAccount: TRadioGroup;
31+ CBBXLastMediaAgeRelation: TComboBox;
32+ LABELastMediaAge: TLabel;
33+ EDITLastMediaAge: TEdit;
3134 procedure PNGBOKClick(Sender: TObject);
3235 procedure FormCreate(Sender: TObject);
3336 private
@@ -86,6 +89,13 @@
8689 else
8790 FAddFollowersParams.MediaRelation := rLessThan;
8891
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+
8999 FAddFollowersParams.BusinessAccount := TBusinessAccount(RAGRBusinessAccount.ItemIndex);
90100
91101 ModalResult := mrOk;
Show on old repository browser