forked from kokosing/trino-rest
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGithubRest.java
2949 lines (2778 loc) · 135 KB
/
GithubRest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package pl.net.was.rest.github;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import io.airlift.slice.Slice;
import io.trino.spi.HostAddress;
import io.trino.spi.Node;
import io.trino.spi.NodeManager;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ColumnMetadata;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorSplitSource;
import io.trino.spi.connector.ConnectorTableHandle;
import io.trino.spi.connector.ConnectorTableMetadata;
import io.trino.spi.connector.Constraint;
import io.trino.spi.connector.ConstraintApplicationResult;
import io.trino.spi.connector.DynamicFilter;
import io.trino.spi.connector.FixedSplitSource;
import io.trino.spi.connector.LimitApplicationResult;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.connector.SchemaTablePrefix;
import io.trino.spi.connector.SortItem;
import io.trino.spi.connector.SortOrder;
import io.trino.spi.connector.TopNApplicationResult;
import io.trino.spi.predicate.Domain;
import io.trino.spi.predicate.Range;
import io.trino.spi.predicate.TupleDomain;
import io.trino.spi.predicate.ValueSet;
import io.trino.spi.statistics.ColumnStatistics;
import io.trino.spi.statistics.Estimate;
import io.trino.spi.statistics.TableStatistics;
import io.trino.spi.type.ArrayType;
import io.trino.spi.type.FixedWidthType;
import io.trino.spi.type.MapType;
import io.trino.spi.type.RowType;
import io.trino.spi.type.TimestampWithTimeZoneType;
import io.trino.spi.type.TypeOperators;
import jakarta.inject.Inject;
import okhttp3.ResponseBody;
import pl.net.was.rest.RateLimitedSplitSource;
import pl.net.was.rest.Rest;
import pl.net.was.rest.RestColumnHandle;
import pl.net.was.rest.RestConfig;
import pl.net.was.rest.RestConnectorSplit;
import pl.net.was.rest.RestModule;
import pl.net.was.rest.RestTableHandle;
import pl.net.was.rest.filter.FilterApplier;
import pl.net.was.rest.filter.FilterType;
import pl.net.was.rest.github.filter.ArtifactFilter;
import pl.net.was.rest.github.filter.CheckRunAnnotationFilter;
import pl.net.was.rest.github.filter.CheckRunFilter;
import pl.net.was.rest.github.filter.CheckSuiteFilter;
import pl.net.was.rest.github.filter.CollaboratorFilter;
import pl.net.was.rest.github.filter.IssueCommentFilter;
import pl.net.was.rest.github.filter.IssueFilter;
import pl.net.was.rest.github.filter.JobFilter;
import pl.net.was.rest.github.filter.JobLogFilter;
import pl.net.was.rest.github.filter.MemberFilter;
import pl.net.was.rest.github.filter.OrgFilter;
import pl.net.was.rest.github.filter.PullCommitFilter;
import pl.net.was.rest.github.filter.PullFilter;
import pl.net.was.rest.github.filter.PullStatisticsFilter;
import pl.net.was.rest.github.filter.RepoCommitFilter;
import pl.net.was.rest.github.filter.RepoFilter;
import pl.net.was.rest.github.filter.ReviewCommentFilter;
import pl.net.was.rest.github.filter.ReviewFilter;
import pl.net.was.rest.github.filter.RunFilter;
import pl.net.was.rest.github.filter.RunnerFilter;
import pl.net.was.rest.github.filter.StepFilter;
import pl.net.was.rest.github.filter.TeamFilter;
import pl.net.was.rest.github.filter.UserFilter;
import pl.net.was.rest.github.filter.WorkflowFilter;
import pl.net.was.rest.github.function.JobLogs;
import pl.net.was.rest.github.model.Artifact;
import pl.net.was.rest.github.model.ArtifactsList;
import pl.net.was.rest.github.model.Envelope;
import pl.net.was.rest.github.model.IssueComment;
import pl.net.was.rest.github.model.Job;
import pl.net.was.rest.github.model.JobsList;
import pl.net.was.rest.github.model.Member;
import pl.net.was.rest.github.model.Organization;
import pl.net.was.rest.github.model.Repository;
import pl.net.was.rest.github.model.ReviewComment;
import pl.net.was.rest.github.model.RunnersList;
import pl.net.was.rest.github.model.Step;
import pl.net.was.rest.github.model.User;
import pl.net.was.rest.github.service.GithubService;
import retrofit2.Call;
import retrofit2.Response;
import java.io.IOException;
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.concurrent.ExecutorService;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.google.common.base.Verify.verify;
import static io.airlift.concurrent.Threads.daemonThreadsNamed;
import static io.trino.spi.StandardErrorCode.INVALID_ORDER_BY;
import static io.trino.spi.StandardErrorCode.INVALID_ROW_FILTER;
import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.BooleanType.BOOLEAN;
import static io.trino.spi.type.IntegerType.INTEGER;
import static io.trino.spi.type.VarbinaryType.VARBINARY;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static pl.net.was.rest.github.function.Artifacts.download;
public class GithubRest
implements Rest
{
// Estimate ratio of one to many relationships
private static final double RELATIONSHIPS_RATIO = 0.01;
// Estimate ratio of issue comments to issues
private static final double ISSUE_COMMENTS_RATIO = 10;
// Estimate number of steps per job
private static final long STEPS_PER_JOB = 5;
Logger log = Logger.getLogger(GithubRest.class.getName());
public static final String SCHEMA_NAME = "default";
private static final int PER_PAGE = 100;
private static int minSplits;
private static List<GithubTable> minSplitTables;
private static double maxSplitsPerSecond;
private static String token;
private static GithubService service;
private static long maxBinaryDownloadSizeBytes;
private final ExecutorService executor = newCachedThreadPool(daemonThreadsNamed(GithubRest.class.getName() + "-%d"));
public static final Map<GithubTable, List<ColumnMetadata>> columns = new ImmutableMap.Builder<GithubTable, List<ColumnMetadata>>()
.put(GithubTable.ORGS, ImmutableList.of(
new ColumnMetadata("login", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("description", VARCHAR),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("company", VARCHAR),
new ColumnMetadata("blog", VARCHAR),
new ColumnMetadata("location", VARCHAR),
new ColumnMetadata("email", VARCHAR),
new ColumnMetadata("twitter_username", VARCHAR),
new ColumnMetadata("is_verified", BOOLEAN),
new ColumnMetadata("has_organization_projects", BOOLEAN),
new ColumnMetadata("has_repository_projects", BOOLEAN),
new ColumnMetadata("public_repos", BIGINT),
new ColumnMetadata("public_gists", BIGINT),
new ColumnMetadata("followers", BIGINT),
new ColumnMetadata("following", BIGINT),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("type", VARCHAR),
new ColumnMetadata("total_private_repos", BIGINT),
new ColumnMetadata("owned_private_repos", BIGINT),
new ColumnMetadata("private_gists", BIGINT),
new ColumnMetadata("disk_usage", BIGINT),
new ColumnMetadata("collaborators", BIGINT),
new ColumnMetadata("billing_email", VARCHAR),
new ColumnMetadata("default_repository_permission", VARCHAR),
new ColumnMetadata("members_can_create_repositories", BOOLEAN),
new ColumnMetadata("two_factor_requirement_enabled", BOOLEAN),
new ColumnMetadata("members_allowed_repository_creation_type", VARCHAR),
new ColumnMetadata("members_can_create_public_repositories", BOOLEAN),
new ColumnMetadata("members_can_create_private_repositories", BOOLEAN),
new ColumnMetadata("members_can_create_internal_repositories", BOOLEAN),
new ColumnMetadata("members_can_create_pages", BOOLEAN),
new ColumnMetadata("members_can_create_public_pages", BOOLEAN),
new ColumnMetadata("members_can_create_private_pages", BOOLEAN),
new ColumnMetadata("members_can_fork_private_repositories", BOOLEAN)))
.put(GithubTable.USERS, ImmutableList.of(
new ColumnMetadata("login", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("avatar_url", VARCHAR),
new ColumnMetadata("gravatar_id", VARCHAR),
new ColumnMetadata("type", VARCHAR),
new ColumnMetadata("site_admin", BOOLEAN),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("company", VARCHAR),
new ColumnMetadata("blog", VARCHAR),
new ColumnMetadata("location", VARCHAR),
new ColumnMetadata("email", VARCHAR),
new ColumnMetadata("hireable", BOOLEAN),
new ColumnMetadata("bio", VARCHAR),
new ColumnMetadata("twitter_username", VARCHAR),
new ColumnMetadata("public_repos", BIGINT),
new ColumnMetadata("public_gists", BIGINT),
new ColumnMetadata("followers", BIGINT),
new ColumnMetadata("following", BIGINT),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3))))
.put(GithubTable.REPOS, ImmutableList.of(
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("full_name", VARCHAR),
new ColumnMetadata("owner_id", BIGINT),
new ColumnMetadata("owner_login", VARCHAR),
new ColumnMetadata("private", BOOLEAN),
new ColumnMetadata("description", VARCHAR),
new ColumnMetadata("fork", BOOLEAN),
new ColumnMetadata("homepage", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("forks_count", BIGINT),
new ColumnMetadata("stargazers_count", BIGINT),
new ColumnMetadata("watchers_count", BIGINT),
new ColumnMetadata("size", BIGINT),
new ColumnMetadata("default_branch", VARCHAR),
new ColumnMetadata("open_issues_count", BIGINT),
new ColumnMetadata("is_template", BOOLEAN),
new ColumnMetadata("topics", new ArrayType(VARCHAR)),
new ColumnMetadata("has_issues", BOOLEAN),
new ColumnMetadata("has_projects", BOOLEAN),
new ColumnMetadata("has_wiki", BOOLEAN),
new ColumnMetadata("has_pages", BOOLEAN),
new ColumnMetadata("has_downloads", BOOLEAN),
new ColumnMetadata("archived", BOOLEAN),
new ColumnMetadata("disabled", BOOLEAN),
new ColumnMetadata("visibility", VARCHAR),
new ColumnMetadata("pushed_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("permissions", new MapType(VARCHAR, BOOLEAN, new TypeOperators()))))
.put(GithubTable.MEMBERS, ImmutableList.of(
new ColumnMetadata("org", VARCHAR),
new ColumnMetadata("team_slug", VARCHAR),
new ColumnMetadata("login", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("avatar_url", VARCHAR),
new ColumnMetadata("gravatar_id", VARCHAR),
new ColumnMetadata("type", VARCHAR),
new ColumnMetadata("site_admin", BOOLEAN)))
.put(GithubTable.TEAMS, ImmutableList.of(
new ColumnMetadata("org", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("node_id", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("html_url", VARCHAR),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("slug", VARCHAR),
new ColumnMetadata("description", VARCHAR),
new ColumnMetadata("privacy", VARCHAR),
new ColumnMetadata("permission", VARCHAR),
new ColumnMetadata("members_url", VARCHAR),
new ColumnMetadata("repositories_url", VARCHAR),
new ColumnMetadata("parent_id", BIGINT),
new ColumnMetadata("parent_slug", VARCHAR)))
.put(GithubTable.COLLABORATORS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("login", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("avatar_url", VARCHAR),
new ColumnMetadata("gravatar_id", VARCHAR),
new ColumnMetadata("type", VARCHAR),
new ColumnMetadata("site_admin", BOOLEAN),
new ColumnMetadata("permission_pull", BOOLEAN),
new ColumnMetadata("permission_triage", BOOLEAN),
new ColumnMetadata("permission_push", BOOLEAN),
new ColumnMetadata("permission_maintain", BOOLEAN),
new ColumnMetadata("permission_admin", BOOLEAN),
new ColumnMetadata("role_name", VARCHAR)))
.put(GithubTable.COMMITS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("sha", VARCHAR),
new ColumnMetadata("commit_message", VARCHAR),
new ColumnMetadata("commit_tree_sha", VARCHAR),
new ColumnMetadata("commit_comment_count", BIGINT),
new ColumnMetadata("commit_verified", BOOLEAN),
new ColumnMetadata("commit_verification_reason", VARCHAR),
new ColumnMetadata("author_name", VARCHAR),
new ColumnMetadata("author_email", VARCHAR),
new ColumnMetadata("author_date", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("author_id", BIGINT),
new ColumnMetadata("author_login", VARCHAR),
new ColumnMetadata("committer_name", VARCHAR),
new ColumnMetadata("committer_email", VARCHAR),
new ColumnMetadata("committer_date", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("committer_id", BIGINT),
new ColumnMetadata("committer_login", VARCHAR),
new ColumnMetadata("parent_shas", new ArrayType(VARCHAR))))
.put(GithubTable.PULLS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("node_id", VARCHAR),
new ColumnMetadata("html_url", VARCHAR),
new ColumnMetadata("diff_url", VARCHAR),
new ColumnMetadata("patch_url", VARCHAR),
new ColumnMetadata("issue_url", VARCHAR),
new ColumnMetadata("commits_url", VARCHAR),
new ColumnMetadata("review_comments_url", VARCHAR),
new ColumnMetadata("review_comment_url", VARCHAR),
new ColumnMetadata("comments_url", VARCHAR),
new ColumnMetadata("statuses_url", VARCHAR),
new ColumnMetadata("number", BIGINT),
new ColumnMetadata("state", VARCHAR),
new ColumnMetadata("locked", BOOLEAN),
new ColumnMetadata("title", VARCHAR),
new ColumnMetadata("user_id", BIGINT),
new ColumnMetadata("user_login", VARCHAR),
new ColumnMetadata("body", VARCHAR),
new ColumnMetadata("label_ids", new ArrayType(BIGINT)),
new ColumnMetadata("label_names", new ArrayType(VARCHAR)),
new ColumnMetadata("milestone_id", BIGINT),
new ColumnMetadata("milestone_title", VARCHAR),
new ColumnMetadata("active_lock_reason", VARCHAR),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("closed_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("merged_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("merge_commit_sha", VARCHAR),
new ColumnMetadata("assignee_id", BIGINT),
new ColumnMetadata("assignee_login", VARCHAR),
new ColumnMetadata("requested_reviewer_ids", new ArrayType(BIGINT)),
new ColumnMetadata("requested_reviewer_logins", new ArrayType(VARCHAR)),
new ColumnMetadata("head_ref", VARCHAR),
new ColumnMetadata("head_sha", VARCHAR),
new ColumnMetadata("base_ref", VARCHAR),
new ColumnMetadata("base_sha", VARCHAR),
new ColumnMetadata("author_association", VARCHAR),
new ColumnMetadata("draft", BOOLEAN),
new ColumnMetadata("auto_merge_enabled_by_id", BIGINT),
new ColumnMetadata("auto_merge_enabled_by_login", VARCHAR),
new ColumnMetadata("auto_merge_method", VARCHAR),
new ColumnMetadata("auto_merge_commit_title", VARCHAR),
new ColumnMetadata("auto_merge_commit_message", VARCHAR)))
.put(GithubTable.PULL_COMMITS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("sha", VARCHAR),
// this column is filled in from request params, it is not returned by the api
new ColumnMetadata("pull_number", BIGINT),
new ColumnMetadata("commit_message", VARCHAR),
new ColumnMetadata("commit_tree_sha", VARCHAR),
new ColumnMetadata("commit_comment_count", BIGINT),
new ColumnMetadata("commit_verified", BOOLEAN),
new ColumnMetadata("commit_verification_reason", VARCHAR),
new ColumnMetadata("author_name", VARCHAR),
new ColumnMetadata("author_email", VARCHAR),
new ColumnMetadata("author_date", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("author_id", BIGINT),
new ColumnMetadata("author_login", VARCHAR),
new ColumnMetadata("committer_name", VARCHAR),
new ColumnMetadata("committer_email", VARCHAR),
new ColumnMetadata("committer_date", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("committer_id", BIGINT),
new ColumnMetadata("committer_login", VARCHAR),
new ColumnMetadata("parent_shas", new ArrayType(VARCHAR))))
.put(GithubTable.PULL_STATS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("pull_number", BIGINT),
new ColumnMetadata("comments", BIGINT),
new ColumnMetadata("review_comments", BIGINT),
new ColumnMetadata("commits", BIGINT),
new ColumnMetadata("additions", BIGINT),
new ColumnMetadata("deletions", BIGINT),
new ColumnMetadata("changed_files", BIGINT),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("closed_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("merged_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3))))
.put(GithubTable.REVIEWS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("id", BIGINT),
// this column is filled in from request params, it is not returned by the api
new ColumnMetadata("pull_number", BIGINT),
new ColumnMetadata("user_id", BIGINT),
new ColumnMetadata("user_login", VARCHAR),
new ColumnMetadata("body", VARCHAR),
new ColumnMetadata("state", VARCHAR),
new ColumnMetadata("submitted_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("commit_id", VARCHAR),
new ColumnMetadata("author_association", VARCHAR)))
.put(GithubTable.REVIEW_COMMENTS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
// this column is filled in from request params, it is not returned by the api
new ColumnMetadata("pull_number", BIGINT),
new ColumnMetadata("pull_request_url", VARCHAR),
new ColumnMetadata("pull_request_review_id", BIGINT),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("diff_hunk", VARCHAR),
new ColumnMetadata("path", VARCHAR),
new ColumnMetadata("position", BIGINT),
new ColumnMetadata("original_position", BIGINT),
new ColumnMetadata("commit_id", VARCHAR),
new ColumnMetadata("original_commit_id", VARCHAR),
new ColumnMetadata("in_reply_to_id", BIGINT),
new ColumnMetadata("user_id", BIGINT),
new ColumnMetadata("user_login", VARCHAR),
new ColumnMetadata("body", VARCHAR),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("author_association", VARCHAR),
new ColumnMetadata("start_line", BIGINT),
new ColumnMetadata("original_start_line", BIGINT),
new ColumnMetadata("start_side", VARCHAR),
new ColumnMetadata("line", BIGINT),
new ColumnMetadata("original_line", BIGINT),
new ColumnMetadata("side", VARCHAR)))
.put(GithubTable.ISSUES, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("node_id", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("repository_url", VARCHAR),
new ColumnMetadata("labels_url", VARCHAR),
new ColumnMetadata("comments_url", VARCHAR),
new ColumnMetadata("events_url", VARCHAR),
new ColumnMetadata("html_url", VARCHAR),
new ColumnMetadata("timeline_url", VARCHAR),
new ColumnMetadata("number", BIGINT),
new ColumnMetadata("state", VARCHAR),
new ColumnMetadata("title", VARCHAR),
new ColumnMetadata("body", VARCHAR),
new ColumnMetadata("user_id", BIGINT),
new ColumnMetadata("user_login", VARCHAR),
new ColumnMetadata("label_ids", new ArrayType(BIGINT)),
new ColumnMetadata("label_names", new ArrayType(VARCHAR)),
new ColumnMetadata("assignee_id", BIGINT),
new ColumnMetadata("assignee_login", VARCHAR),
new ColumnMetadata("milestone_id", BIGINT),
new ColumnMetadata("milestone_title", VARCHAR),
new ColumnMetadata("locked", BOOLEAN),
new ColumnMetadata("active_lock_reason", VARCHAR),
new ColumnMetadata("comments", BIGINT),
new ColumnMetadata("closed_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("closed_by_id", BIGINT),
new ColumnMetadata("closed_by_login", VARCHAR),
new ColumnMetadata("author_association", VARCHAR),
new ColumnMetadata("draft", BOOLEAN),
new ColumnMetadata("reactions_url", VARCHAR),
new ColumnMetadata("reactions_total_count", INTEGER),
new ColumnMetadata("app_id", BIGINT),
new ColumnMetadata("app_slug", VARCHAR),
new ColumnMetadata("app_name", VARCHAR)))
.put(GithubTable.ISSUE_COMMENTS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("issue_number", BIGINT),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("node_id", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("html_url", VARCHAR),
new ColumnMetadata("body", VARCHAR),
new ColumnMetadata("user_id", BIGINT),
new ColumnMetadata("user_login", VARCHAR),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("issue_url", VARCHAR),
new ColumnMetadata("author_association", VARCHAR),
new ColumnMetadata("reactions_url", VARCHAR),
new ColumnMetadata("reactions_total_count", INTEGER),
new ColumnMetadata("app_id", BIGINT),
new ColumnMetadata("app_slug", VARCHAR),
new ColumnMetadata("app_name", VARCHAR)))
.put(GithubTable.WORKFLOWS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("node_id", VARCHAR),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("path", VARCHAR),
new ColumnMetadata("state", VARCHAR),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("html_url", VARCHAR),
new ColumnMetadata("badge_url", VARCHAR)))
.put(GithubTable.RUNS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("node_id", VARCHAR),
new ColumnMetadata("check_suite_id", BIGINT),
new ColumnMetadata("check_suite_node_id", VARCHAR),
new ColumnMetadata("head_branch", VARCHAR),
new ColumnMetadata("head_sha", VARCHAR),
new ColumnMetadata("run_number", BIGINT),
new ColumnMetadata("run_attempt", INTEGER),
new ColumnMetadata("event", VARCHAR),
new ColumnMetadata("status", VARCHAR),
new ColumnMetadata("conclusion", VARCHAR),
new ColumnMetadata("workflow_id", BIGINT),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("run_started_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3))))
.put(GithubTable.JOBS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("run_id", BIGINT),
new ColumnMetadata("run_attempt", INTEGER),
new ColumnMetadata("node_id", VARCHAR),
new ColumnMetadata("head_sha", VARCHAR),
new ColumnMetadata("status", VARCHAR),
new ColumnMetadata("conclusion", VARCHAR),
new ColumnMetadata("started_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("completed_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("steps_count", INTEGER)))
.put(GithubTable.JOB_LOGS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("job_id", BIGINT),
new ColumnMetadata("size_in_bytes", BIGINT),
new ColumnMetadata("part_number", INTEGER),
new ColumnMetadata("contents", VARBINARY)))
.put(GithubTable.STEPS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("run_id", BIGINT),
new ColumnMetadata("run_attempt", INTEGER),
new ColumnMetadata("job_id", BIGINT),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("status", VARCHAR),
new ColumnMetadata("conclusion", VARCHAR),
new ColumnMetadata("number", BIGINT),
new ColumnMetadata("started_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("completed_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3))))
.put(GithubTable.ARTIFACTS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("run_id", BIGINT),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("size_in_bytes", BIGINT),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("archive_download_url", VARCHAR),
new ColumnMetadata("expired", BOOLEAN),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("expires_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("filename", VARCHAR),
new ColumnMetadata("path", VARCHAR),
new ColumnMetadata("mimetype", VARCHAR),
new ColumnMetadata("file_size_in_bytes", BIGINT),
new ColumnMetadata("part_number", INTEGER),
new ColumnMetadata("contents", VARBINARY)))
.put(GithubTable.RUNNERS, ImmutableList.of(
new ColumnMetadata("org", VARCHAR),
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("os", VARCHAR),
new ColumnMetadata("status", VARCHAR),
new ColumnMetadata("busy", BOOLEAN),
new ColumnMetadata("label_ids", new ArrayType(BIGINT)),
new ColumnMetadata("label_names", new ArrayType(VARCHAR))))
.put(GithubTable.CHECK_SUITES, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("ref", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("head_branch", VARCHAR),
new ColumnMetadata("head_sha", VARCHAR),
new ColumnMetadata("status", VARCHAR),
new ColumnMetadata("conclusion", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("before", VARCHAR),
new ColumnMetadata("after", VARCHAR),
new ColumnMetadata("pull_request_numbers", new ArrayType(BIGINT)),
new ColumnMetadata("app_id", BIGINT),
new ColumnMetadata("app_slug", VARCHAR),
new ColumnMetadata("app_name", VARCHAR),
new ColumnMetadata("created_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("updated_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("latest_check_runs_count", BIGINT),
new ColumnMetadata("check_runs_url", VARCHAR)))
.put(GithubTable.CHECK_RUNS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("ref", VARCHAR),
new ColumnMetadata("id", BIGINT),
new ColumnMetadata("head_sha", VARCHAR),
new ColumnMetadata("external_id", VARCHAR),
new ColumnMetadata("url", VARCHAR),
new ColumnMetadata("html_url", VARCHAR),
new ColumnMetadata("details_url", VARCHAR),
new ColumnMetadata("status", VARCHAR),
new ColumnMetadata("conclusion", VARCHAR),
new ColumnMetadata("started_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("completed_at", TimestampWithTimeZoneType.createTimestampWithTimeZoneType(3)),
new ColumnMetadata("output_title", VARCHAR),
new ColumnMetadata("output_summary", VARCHAR),
new ColumnMetadata("output_text", VARCHAR),
new ColumnMetadata("annotations_count", BIGINT),
new ColumnMetadata("annotations_url", VARCHAR),
new ColumnMetadata("name", VARCHAR),
new ColumnMetadata("check_suite_id", BIGINT),
new ColumnMetadata("app_id", BIGINT),
new ColumnMetadata("app_slug", VARCHAR),
new ColumnMetadata("app_name", VARCHAR)))
.put(GithubTable.CHECK_RUN_ANNOTATIONS, ImmutableList.of(
new ColumnMetadata("owner", VARCHAR),
new ColumnMetadata("repo", VARCHAR),
new ColumnMetadata("check_run_id", BIGINT),
new ColumnMetadata("path", VARCHAR),
new ColumnMetadata("start_line", INTEGER),
new ColumnMetadata("end_line", INTEGER),
new ColumnMetadata("start_column", INTEGER),
new ColumnMetadata("end_column", INTEGER),
new ColumnMetadata("annotation_level", VARCHAR),
new ColumnMetadata("title", VARCHAR),
new ColumnMetadata("message", VARCHAR),
new ColumnMetadata("raw_details", VARCHAR),
new ColumnMetadata("blob_href", VARCHAR)))
.build();
// These are only used by tableStatistics to estimate row counts, so they don't have to be complete
public static final Map<GithubTable, Map<String, KeyType>> keyColumns = new ImmutableMap.Builder<GithubTable, Map<String, KeyType>>()
.put(GithubTable.ISSUES, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"url", KeyType.PRIMARY_KEY,
"user_id", KeyType.FOREIGN_KEY))
.put(GithubTable.ISSUE_COMMENTS, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"issue_number", KeyType.FOREIGN_KEY,
"issue_url", KeyType.FOREIGN_KEY,
"user_id", KeyType.FOREIGN_KEY))
.put(GithubTable.WORKFLOWS, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"repo", KeyType.FOREIGN_KEY))
.put(GithubTable.RUNS, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"run_number", KeyType.FOREIGN_KEY,
"run_attempt", KeyType.FOREIGN_KEY))
.put(GithubTable.JOBS, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"run_id", KeyType.FOREIGN_KEY,
"run_attempt", KeyType.FOREIGN_KEY))
.put(GithubTable.STEPS, ImmutableMap.of(
"job_id", KeyType.FOREIGN_KEY,
"run_id", KeyType.FOREIGN_KEY,
"run_attempt", KeyType.FOREIGN_KEY))
.put(GithubTable.ARTIFACTS, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"run_id", KeyType.FOREIGN_KEY))
.put(GithubTable.RUNNERS, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY))
.put(GithubTable.CHECK_SUITES, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"ref", KeyType.FOREIGN_KEY))
.put(GithubTable.CHECK_RUNS, ImmutableMap.of(
"id", KeyType.PRIMARY_KEY,
"ref", KeyType.FOREIGN_KEY,
"check_suite_id", KeyType.FOREIGN_KEY))
.put(GithubTable.CHECK_RUN_ANNOTATIONS, ImmutableMap.of(
"check_run_id", KeyType.FOREIGN_KEY))
.build();
private enum KeyType
{
PRIMARY_KEY,
FOREIGN_KEY
}
private final Map<GithubTable, Function<RestTableHandle, Iterable<List<?>>>> rowGetters = new ImmutableMap.Builder<GithubTable, Function<RestTableHandle, Iterable<List<?>>>>()
.put(GithubTable.ORGS, this::getOrgs)
.put(GithubTable.USERS, this::getUsers)
.put(GithubTable.REPOS, this::getRepos)
.put(GithubTable.MEMBERS, this::getMembers)
.put(GithubTable.TEAMS, this::getTeams)
.put(GithubTable.COLLABORATORS, this::getCollaborators)
.put(GithubTable.COMMITS, this::getRepoCommits)
.put(GithubTable.PULLS, this::getPulls)
.put(GithubTable.PULL_COMMITS, this::getPullCommits)
.put(GithubTable.PULL_STATS, this::getPullStats)
.put(GithubTable.REVIEWS, this::getReviews)
.put(GithubTable.REVIEW_COMMENTS, this::getReviewComments)
.put(GithubTable.ISSUES, this::getIssues)
.put(GithubTable.ISSUE_COMMENTS, this::getIssueComments)
.put(GithubTable.WORKFLOWS, this::getWorkflows)
.put(GithubTable.RUNS, this::getRuns)
.put(GithubTable.JOBS, this::getJobs)
.put(GithubTable.JOB_LOGS, this::getJobLogs)
.put(GithubTable.STEPS, this::getSteps)
.put(GithubTable.ARTIFACTS, this::getArtifacts)
.put(GithubTable.RUNNERS, this::getRunners)
.put(GithubTable.CHECK_SUITES, this::getCheckSuites)
.put(GithubTable.CHECK_RUNS, this::getCheckRuns)
.put(GithubTable.CHECK_RUN_ANNOTATIONS, this::getCheckRunAnnotations)
.build();
private final Map<GithubTable, Function<RestTableHandle, Long>> rowCountGetters = new ImmutableMap.Builder<GithubTable, Function<RestTableHandle, Long>>()
.put(GithubTable.WORKFLOWS, this::getWorkflowsCount)
.put(GithubTable.RUNS, this::getRunsCount)
.put(GithubTable.JOBS, this::getJobsCount)
.put(GithubTable.STEPS, this::getStepsCount)
// artifacts are in an envelope, but since artifact contents are denormalized into separate rows so there's no way to know how many actual rows there are
.put(GithubTable.RUNNERS, this::getRunnersCount)
.put(GithubTable.CHECK_SUITES, this::getCheckSuitesCount)
.put(GithubTable.CHECK_RUNS, this::getCheckRunsCount)
.build();
// The first sortItem is the default
private final Map<GithubTable, List<SortItem>> supportedTableSort = new ImmutableMap.Builder<GithubTable, List<SortItem>>()
.put(GithubTable.ORGS, ImmutableList.of(
new SortItem("created_at", SortOrder.ASC_NULLS_LAST)))
.put(GithubTable.REPOS, ImmutableList.of(
new SortItem("full_name", SortOrder.ASC_NULLS_LAST),
new SortItem("full_name", SortOrder.DESC_NULLS_LAST),
new SortItem("created_at", SortOrder.DESC_NULLS_LAST),
new SortItem("created_at", SortOrder.ASC_NULLS_LAST),
new SortItem("updated_at", SortOrder.DESC_NULLS_LAST),
new SortItem("updated_at", SortOrder.ASC_NULLS_LAST),
new SortItem("pushed_at", SortOrder.ASC_NULLS_LAST),
new SortItem("pushed_at", SortOrder.DESC_NULLS_LAST)))
.put(GithubTable.COMMITS, ImmutableList.of(
new SortItem("committer_date", SortOrder.DESC_NULLS_LAST)))
.put(GithubTable.PULLS, ImmutableList.of(
new SortItem("created_at", SortOrder.DESC_NULLS_LAST),
new SortItem("created_at", SortOrder.ASC_NULLS_LAST),
new SortItem("updated_at", SortOrder.ASC_NULLS_LAST),
new SortItem("updated_at", SortOrder.DESC_NULLS_LAST)))
.put(GithubTable.PULL_COMMITS, ImmutableList.of(
new SortItem("committer_date", SortOrder.ASC_NULLS_LAST)))
.put(GithubTable.REVIEWS, ImmutableList.of(
new SortItem("created_at", SortOrder.ASC_NULLS_LAST)))
.put(GithubTable.REVIEW_COMMENTS, ImmutableList.of(
new SortItem("id", SortOrder.ASC_NULLS_LAST),
new SortItem("id", SortOrder.DESC_NULLS_LAST),
new SortItem("created_at", SortOrder.DESC_NULLS_LAST),
new SortItem("created_at", SortOrder.ASC_NULLS_LAST)))
.put(GithubTable.ISSUES, ImmutableList.of(
new SortItem("created_at", SortOrder.DESC_NULLS_LAST),
new SortItem("created_at", SortOrder.ASC_NULLS_LAST),
new SortItem("updated_at", SortOrder.DESC_NULLS_LAST),
new SortItem("updated_at", SortOrder.ASC_NULLS_LAST),
new SortItem("comments", SortOrder.DESC_NULLS_LAST),
new SortItem("comments", SortOrder.ASC_NULLS_LAST)))
.put(GithubTable.ISSUE_COMMENTS, ImmutableList.of(
new SortItem("id", SortOrder.ASC_NULLS_LAST),
new SortItem("id", SortOrder.DESC_NULLS_LAST),
new SortItem("created_at", SortOrder.ASC_NULLS_LAST),
new SortItem("created_at", SortOrder.DESC_NULLS_LAST)))
.put(GithubTable.WORKFLOWS, ImmutableList.of(
new SortItem("created_at", SortOrder.DESC_NULLS_LAST)))
.put(GithubTable.RUNS, ImmutableList.of(
new SortItem("created_at", SortOrder.DESC_NULLS_LAST)))
.put(GithubTable.JOBS, ImmutableList.of(
new SortItem("started_at", SortOrder.ASC_NULLS_LAST)))
.put(GithubTable.STEPS, ImmutableList.of(
new SortItem("job_id", SortOrder.ASC_NULLS_LAST)))
.put(GithubTable.ARTIFACTS, ImmutableList.of(
new SortItem("id", SortOrder.ASC_NULLS_LAST)))
.build();
// TODO add tests that would verify this using getSqlType(), print the expected string so its easy to copy&paste
// TODO consider moving to a separate class
public static final String ORG_ROW_TYPE = "row(" +
"login varchar, " +
"id bigint, " +
"description varchar, " +
"name varchar, " +
"company varchar, " +
"blog varchar, " +
"location varchar, " +
"email varchar, " +
"twitter_username varchar, " +
"is_verified boolean, " +
"has_organization_projects boolean, " +
"has_repository_projects boolean, " +
"public_repos bigint, " +
"public_gists bigint, " +
"followers bigint, " +
"following bigint, " +
"created_at timestamp(3) with time zone, " +
"updated_at timestamp(3) with time zone, " +
"type varchar, " +
"total_private_repos bigint, " +
"owned_private_repos bigint, " +
"private_gists bigint, " +
"disk_usage bigint, " +
"collaborators bigint, " +
"billing_email varchar, " +
"default_repository_permission varchar, " +
"members_can_create_repositories boolean, " +
"two_factor_requirement_enabled boolean, " +
"members_allowed_repository_creation_type varchar, " +
"members_can_create_public_repositories boolean, " +
"members_can_create_private_repositories boolean, " +
"members_can_create_internal_repositories boolean, " +
"members_can_create_pages boolean, " +
"members_can_create_public_pages boolean, " +
"members_can_create_private_pages boolean, " +
"members_can_fork_private_repositories boolean" +
")";
public static final String ORGS_TABLE_TYPE = "array(" + ORG_ROW_TYPE + ")";
public static final String USER_ROW_TYPE = "row(" +
"login varchar, " +
"id bigint, " +
"avatar_url varchar, " +
"gravatar_id varchar, " +
"type varchar, " +
"site_admin boolean, " +
"name varchar, " +
"company varchar, " +
"blog varchar, " +
"location varchar, " +
"email varchar, " +
"hireable boolean, " +
"bio varchar, " +
"twitter_username varchar, " +
"public_repos bigint, " +
"public_gists bigint, " +
"followers bigint, " +
"following bigint, " +
"created_at timestamp(3) with time zone, " +
"updated_at timestamp(3) with time zone" +
")";
public static final String USERS_TABLE_TYPE = "array(" + USER_ROW_TYPE + ")";
public static final String REPOS_TABLE_TYPE = "array(row(" +
"id bigint, " +
"name varchar, " +
"full_name varchar, " +
"owner_id bigint, " +
"owner_login varchar, " +
"private boolean, " +
"description varchar, " +
"fork boolean, " +
"homepage varchar, " +
"url varchar, " +
"forks_count bigint, " +
"stargazers_count bigint, " +
"watchers_count bigint, " +
"size bigint, " +
"default_branch varchar, " +
"open_issues_count bigint, " +
"is_template boolean, " +
"topics array(varchar), " +
"has_issues boolean, " +
"has_projects boolean, " +
"has_wiki boolean, " +
"has_pages boolean, " +
"has_downloads boolean, " +
"archived boolean, " +
"disabled boolean, " +
"visibility varchar, " +
"pushed_at timestamp(3) with time zone, " +
"created_at timestamp(3) with time zone, " +
"updated_at timestamp(3) with time zone, " +
"permissions map(varchar, boolean)" +
"))";
public static final String MEMBER_ROW_TYPE = "row(" +
"org varchar, " +
"team_slug varchar, " +
"login varchar, " +
"id bigint, " +
"avatar_url varchar, " +
"gravatar_id varchar, " +
"type varchar, " +
"site_admin boolean" +
")";
public static final String MEMBERS_TABLE_TYPE = "array(" + MEMBER_ROW_TYPE + ")";
public static final String TEAM_ROW_TYPE = "row(" +
"org varchar, " +
"id bigint, " +
"node_id varchar, " +
"url varchar, " +
"html_url varchar, " +
"name varchar, " +
"slug varchar, " +
"description varchar, " +
"privacy varchar, " +
"permission varchar, " +
"members_url varchar, " +
"repositories_url varchar, " +
"parent_id bigint, " +
"parent_slug boolean" +
")";
public static final String TEAMS_TABLE_TYPE = "array(" + TEAM_ROW_TYPE + ")";
public static final String COLLABORATOR_ROW_TYPE = "row(" +
"owner varchar, " +
"repo varchar, " +
"login varchar, " +
"id bigint, " +
"avatar_url varchar, " +
"gravatar_id varchar, " +
"type varchar, " +
"site_admin boolean, " +
"permission_pull boolean, " +
"permission_triage boolean, " +
"permission_push boolean, " +
"permission_maintain boolean, " +
"permission_admin boolean, " +
"role_name varchar" +
")";
public static final String COLLABORATOR_TABLE_TYPE = "array(" + COLLABORATOR_ROW_TYPE + ")";
public static final String COMMITS_TABLE_TYPE = "array(row(" +
"owner varchar, " +
"repo varchar, " +
"sha varchar, " +
"commit_message varchar, " +
"commit_tree_sha varchar, " +
"commit_comment_count bigint, " +
"commit_verified boolean, " +
"commit_verification_reason varchar, " +
"author_name varchar, " +
"author_email varchar, " +
"author_date timestamp(3) with time zone, " +
"author_id bigint, " +
"author_login varchar, " +
"committer_name varchar, " +
"committer_email varchar, " +
"committer_date timestamp(3) with time zone, " +
"committer_id bigint, " +
"committer_login varchar, " +
"parent_shas array(varchar)" +
"))";
public static final String PULLS_TABLE_TYPE = "array(row(" +
"owner varchar, " +
"repo varchar, " +
"url varchar, " +
"id bigint, " +
"node_id varchar, " +
"html_url varchar, " +
"diff_url varchar, " +
"patch_url varchar, " +
"issue_url varchar, " +
"commits_url varchar, " +
"review_comments_url varchar, " +
"review_comment_url varchar, " +
"comments_url varchar, " +
"statuses_url varchar, " +
"number bigint, " +
"state varchar, " +
"locked boolean, " +
"title varchar, " +
"user_id bigint, " +
"user_login varchar, " +
"body varchar, " +
"label_ids array(bigint), " +
"label_names array(varchar), " +
"milestone_id bigint, " +
"milestone_title varchar, " +
"active_lock_reason varchar, " +
"created_at timestamp(3) with time zone, " +
"updated_at timestamp(3) with time zone, " +
"closed_at timestamp(3) with time zone, " +
"merged_at timestamp(3) with time zone, " +
"merge_commit_sha varchar, " +
"assignee_id bigint, " +
"assignee_login varchar, " +
"requested_reviewer_ids array(bigint), " +
"requested_reviewer_logins array(varchar), " +
"head_ref varchar, " +