This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e56b17  [BEAM-13531] playground - fetch example info only once
     new 0109733  Merge pull request #16340 from [BEAM-13531] [Playground] 
Fetch example info (source, logs, outputs) only once
5e56b17 is described below

commit 5e56b17ec2861122d86fac8f8ddd8f59127e835a
Author: Aydar Farrakhov <[email protected]>
AuthorDate: Thu Dec 23 14:36:09 2021 +0300

    [BEAM-13531] playground - fetch example info only once
---
 playground/frontend/lib/modules/examples/models/example_model.dart  | 5 +++++
 playground/frontend/lib/pages/playground/states/examples_state.dart | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/playground/frontend/lib/modules/examples/models/example_model.dart 
b/playground/frontend/lib/modules/examples/models/example_model.dart
index 7286bff..c0d9116 100644
--- a/playground/frontend/lib/modules/examples/models/example_model.dart
+++ b/playground/frontend/lib/modules/examples/models/example_model.dart
@@ -65,6 +65,11 @@ class ExampleModel with Comparable<ExampleModel> {
     this.outputs = outputs;
   }
 
+  bool isInfoFetched() {
+    // checking only source, because outputs/logs can be empty
+    return source?.isNotEmpty ?? false;
+  }
+
   @override
   int compareTo(ExampleModel other) {
     return name.toLowerCase().compareTo(other.name.toLowerCase());
diff --git 
a/playground/frontend/lib/pages/playground/states/examples_state.dart 
b/playground/frontend/lib/pages/playground/states/examples_state.dart
index 2da5fc8..acc9cfe 100644
--- a/playground/frontend/lib/pages/playground/states/examples_state.dart
+++ b/playground/frontend/lib/pages/playground/states/examples_state.dart
@@ -55,6 +55,9 @@ class ExampleState with ChangeNotifier {
   }
 
   Future<ExampleModel> loadExampleInfo(ExampleModel example, SDK sdk) async {
+    if (example.isInfoFetched()) {
+      return example;
+    }
     String source = await getExampleSource(example.path, sdk);
     example.setSource(source);
     final outputs = await getExampleOutput(example.path, sdk);

Reply via email to